code
DveloxSoft Bucket Guías de integración para desarrolladores

Acceder a archivos

Interactúa con archivos y directorios dentro de un contenedor. Todos los endpoints aceptan un slug de contenedor y una ruta relativa a la raíz del contenedor. Los contenedores públicos permiten lecturas sin autenticación.

Listar un directorio

Llama a GET /files/:containerSlug/*path. Si la ruta es un directorio, el servidor devuelve un listado JSON. Si es un archivo, devuelve el flujo del archivo.

typescript
const response = await fetch(
  `https://bucket.dveloxsoft.com/api/files/${containerSlug}/${encodeURIComponent(path)}`,
  {
    headers: {
      'Authorization': 'ApiKey <api_key>'
    }
  }
);

if (!response.ok) {
  const error = await response.json();
  throw new Error(error.message || 'Failed to list directory');
}

const listing = await response.json();
console.log('Current path:', listing.path);
for (const item of listing.items) {
  console.log(item.type, item.name, item.path);
}

Descargar o transmitir un archivo

Solicita la ruta del archivo con GET /files/:containerSlug/*path. La respuesta es un flujo binario. En un navegador puedes abrirlo directamente o convertirlo a una URL de blob.

typescript
// Open in browser tab
window.open(
  `https://bucket.dveloxsoft.com/api/files/${containerSlug}/${encodeURIComponent(filePath)}`,
  '_blank'
);

// Or stream as blob in JavaScript
const response = await fetch(
  `https://bucket.dveloxsoft.com/api/files/${containerSlug}/${encodeURIComponent(filePath)}`,
  {
    headers: { 'Authorization': 'Bearer <jwt_token>' }
  }
);

const blob = await response.blob();
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = 'filename.ext';
link.click();
URL.revokeObjectURL(url);

Crear un directorio

Envía POST /files/:containerSlug/*path/directory con la ruta del directorio deseado en la URL.

typescript
const response = await fetch(
  `https://bucket.dveloxsoft.com/api/files/${containerSlug}/${encodeURIComponent('new/folder/path')}/directory`,
  {
    method: 'POST',
    headers: {
      'Authorization': 'ApiKey <api_key>'
    }
  }
);

if (!response.ok) {
  const error = await response.json();
  throw new Error(error.message || 'Failed to create directory');
}

console.log('Directory created');

Mover o renombrar

Envía POST /files/:containerSlug/*path/move con la ruta de destino en el cuerpo.

typescript
const response = await fetch(
  `https://bucket.dveloxsoft.com/api/files/${containerSlug}/${encodeURIComponent('old/path.txt')}/move`,
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'ApiKey <api_key>'
    },
    body: JSON.stringify({
      newPath: 'new/path.txt'
    })
  }
);

if (!response.ok) {
  const error = await response.json();
  throw new Error(error.message || 'Failed to move item');
}

console.log('Item moved');

Eliminar

Envía DELETE /files/:containerSlug/*path. Esto elimina permanentemente el archivo o directorio.

typescript
const response = await fetch(
  `https://bucket.dveloxsoft.com/api/files/${containerSlug}/${encodeURIComponent('path/to/file.txt')}`,
  {
    method: 'DELETE',
    headers: {
      'Authorization': 'ApiKey <api_key>'
    }
  }
);

if (!response.ok) {
  const error = await response.json();
  throw new Error(error.message || 'Failed to delete item');
}

console.log('Item deleted');