Ir al contenido
v2.7

Storage

Buckets y archivos: subir, descargar, ver y previsualizar imágenes.

Buckets y archivos: subir, descargar, ver y previsualizar imágenes.

Clase Storage: 13 métodos (8 en @owbase/web, 13 en @owbase/node). Las descripciones de los métodos están en inglés. Los ejemplos usan la forma de objeto de los parámetros; cambia los valores entre < y > por los tuyos.

Listar buckets

GET /storage/buckets · página del método

SDK: solo @owbase/node

Get a list of all the storage buckets. You can use the query params to filter your results.

Parámetro Tipo Obligatorio Descripción
queries string[] no Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus, transformations, stripMetadata
search string no Search term to filter your list results. Max length: 256 chars.
total boolean no When set to false, the total count returned will be 0 and will not be calculated.

Acceso: clave de API con el alcance buckets.read.

@owbase/node
import { Client, Storage } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const storage = new Storage(client);
const result = await storage.listBuckets({
queries: [], // optional
search: '<SEARCH>', // optional
total: false, // optional
});

Crear bucket

POST /storage/buckets · página del método

SDK: solo @owbase/node

Create a new storage bucket.

Parámetro Tipo Obligatorio Descripción
bucketId string sí Unique Id. Choose a custom ID or generate a random ID with ID.unique(). Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.
name string sí Bucket name
permissions string[] no An array of permission strings. By default, no user is granted with any permissions. Learn more about permissions.
fileSecurity boolean no Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. Learn more about permissions.
enabled boolean no Is bucket enabled? When set to ‘disabled’, users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled.
maximumFileSize number no Maximum file size allowed in bytes. Maximum allowed value is 0B.
allowedFileExtensions string[] no Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.
compression Compression no Compression algorithm chosen for compression. Can be one of none, gzip, or zstd, For file size above 20MB compression is skipped even if it’s enabled Valores: none, gzip, zstd.
encryption boolean no Is encryption enabled? For file size above 20MB encryption is skipped even if it’s enabled
antivirus boolean no Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it’s enabled
transformations boolean no Are image transformations enabled?
description string no Optional description for the bucket.
stripMetadata boolean no Remove metadata such as location, device and capture time from uploaded images. The color profile and orientation are kept. For file size above 20MB metadata is not removed even if it’s enabled.

Acceso: clave de API con el alcance buckets.write.

@owbase/node
import { Client, Storage, Permission, Role, Compression } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const storage = new Storage(client);
const result = await storage.createBucket({
bucketId: '<BUCKET_ID>',
name: '<NAME>',
permissions: [Permission.read(Role.any())], // optional
fileSecurity: false, // optional
enabled: false, // optional
maximumFileSize: 1, // optional
allowedFileExtensions: [], // optional
compression: Compression.None, // optional
encryption: false, // optional
antivirus: false, // optional
transformations: false, // optional
description: '<DESCRIPTION>', // optional
stripMetadata: false, // optional
});

Obtener bucket

GET /storage/buckets/{bucketId} · página del método

SDK: solo @owbase/node

Get a storage bucket by its unique ID. This endpoint response returns a JSON object with the storage bucket metadata.

Parámetro Tipo Obligatorio Descripción
bucketId string sí Bucket unique ID.

Acceso: clave de API con el alcance buckets.read.

@owbase/node
import { Client, Storage } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const storage = new Storage(client);
const result = await storage.getBucket({
bucketId: '<BUCKET_ID>',
});

Actualizar bucket

PUT /storage/buckets/{bucketId} · página del método

SDK: solo @owbase/node

Update a storage bucket by its unique ID.

Parámetro Tipo Obligatorio Descripción
bucketId string sí Bucket unique ID.
name string sí Bucket name
permissions string[] no An array of permission strings. By default, the current permissions are inherited. Learn more about permissions.
fileSecurity boolean no Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. Learn more about permissions.
enabled boolean no Is bucket enabled? When set to ‘disabled’, users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled.
maximumFileSize number no Maximum file size allowed in bytes. Maximum allowed value is 0B.
allowedFileExtensions string[] no Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.
compression Compression no Compression algorithm chosen for compression. Can be one of none, gzip, or zstd, For file size above 20MB compression is skipped even if it’s enabled Valores: none, gzip, zstd.
encryption boolean no Is encryption enabled? For file size above 20MB encryption is skipped even if it’s enabled
antivirus boolean no Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it’s enabled
transformations boolean no Are image transformations enabled?
description string no Optional description for the bucket.
stripMetadata boolean no Remove metadata such as location, device and capture time from uploaded images. The color profile and orientation are kept. For file size above 20MB metadata is not removed even if it’s enabled. By default, the current setting is kept.

Acceso: clave de API con el alcance buckets.write.

@owbase/node
import { Client, Storage, Permission, Role, Compression } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const storage = new Storage(client);
const result = await storage.updateBucket({
bucketId: '<BUCKET_ID>',
name: '<NAME>',
permissions: [Permission.read(Role.any())], // optional
fileSecurity: false, // optional
enabled: false, // optional
maximumFileSize: 1, // optional
allowedFileExtensions: [], // optional
compression: Compression.None, // optional
encryption: false, // optional
antivirus: false, // optional
transformations: false, // optional
description: '<DESCRIPTION>', // optional
stripMetadata: false, // optional
});

Eliminar bucket

DELETE /storage/buckets/{bucketId} · página del método

SDK: solo @owbase/node

Delete a storage bucket by its unique ID.

Parámetro Tipo Obligatorio Descripción
bucketId string sí Bucket unique ID.

Acceso: clave de API con el alcance buckets.write.

@owbase/node
import { Client, Storage } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const storage = new Storage(client);
const result = await storage.deleteBucket({
bucketId: '<BUCKET_ID>',
});

Listar archivos

GET /storage/buckets/{bucketId}/files · página del método

SDK: @owbase/web y @owbase/node

Get a list of all the user files. You can use the query params to filter your results.

Parámetro Tipo Obligatorio Descripción
bucketId string sí Storage bucket unique ID. You can create a new storage bucket using the Storage service server integration.
queries string[] no Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, folder, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded
search string no Search term to filter your list results. Max length: 256 chars.
total boolean no When set to false, the total count returned will be 0 and will not be calculated.

Acceso: clave de API con el alcance files.read o sesión del usuario, o incluso sin sesión (vale lo que permitan los permisos del recurso).

@owbase/web
import { Client, Storage } from '@owbase/web';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
const storage = new Storage(client);
const result = await storage.listFiles({
bucketId: '<BUCKET_ID>',
queries: [], // optional
search: '<SEARCH>', // optional
total: false, // optional
});
console.log(result);
@owbase/node
import { Client, Storage } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const storage = new Storage(client);
const result = await storage.listFiles({
bucketId: '<BUCKET_ID>',
queries: [], // optional
search: '<SEARCH>', // optional
total: false, // optional
});

Crear archivo

POST /storage/buckets/{bucketId}/files · página del método

SDK: @owbase/web y @owbase/node

Create a new file. Before using this route, you should create a new bucket resource using either a server integration API or directly from your Owbase console.

Larger files should be uploaded using multiple requests with the content-range header to send a partial request with a maximum supported chunk of 5MB. The content-range header values should always be in bytes.

When the first request is sent, the server will return the File object, and the subsequent part request must include the file’s id in x-owbase-id header to allow the server to know that the partial upload is for the existing file and not for a new one.

If you’re creating a new file using one of the Owbase SDKs, all the chunking logic will be managed by the SDK internally.

Parámetro Tipo Obligatorio Descripción
bucketId string sí Storage bucket unique ID. You can create a new storage bucket using the Storage service server integration.
fileId string sí File ID. Choose a custom ID or generate a random ID with ID.unique(). Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.
file File (en node, también InputFile) sí Binary file. Owbase SDKs provide helpers to handle file input. Learn about file input.
permissions string[] no An array of permission strings. By default, only the current user is granted all permissions. Learn more about permissions.
folder string no Virtual folder to place the file in, for example “photos/2026”. Nest folders with /. Defaults to the bucket root.
onProgress (progress: UploadProgress) => void no Callback called after each uploaded chunk with the upload progress ($id, progress in percent, sizeUploaded, chunksTotal, chunksUploaded).

Acceso: clave de API con el alcance files.write o sesión del usuario, o incluso sin sesión (vale lo que permitan los permisos del recurso).

@owbase/web
import { Client, Storage, Permission, Role } from '@owbase/web';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
const storage = new Storage(client);
const result = await storage.createFile({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
file: document.getElementById('uploader').files[0],
permissions: [Permission.read(Role.any())], // optional
folder: 'photos/2026', // optional
});
console.log(result);
@owbase/node
import { Client, Storage, Permission, Role } from '@owbase/node';
import { InputFile } from '@owbase/node/file';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const storage = new Storage(client);
const result = await storage.createFile({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
file: InputFile.fromPath('/path/to/file', 'filename'),
permissions: [Permission.read(Role.any())], // optional
folder: 'photos/2026', // optional
});

Obtener archivo

GET /storage/buckets/{bucketId}/files/{fileId} · página del método

SDK: @owbase/web y @owbase/node

Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata.

Parámetro Tipo Obligatorio Descripción
bucketId string sí Storage bucket unique ID. You can create a new storage bucket using the Storage service server integration.
fileId string sí File ID.

Acceso: clave de API con el alcance files.read o sesión del usuario, o incluso sin sesión (vale lo que permitan los permisos del recurso).

@owbase/web
import { Client, Storage } from '@owbase/web';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
const storage = new Storage(client);
const result = await storage.getFile({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
});
console.log(result);
@owbase/node
import { Client, Storage } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const storage = new Storage(client);
const result = await storage.getFile({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
});

Actualizar archivo

PUT /storage/buckets/{bucketId}/files/{fileId} · página del método

SDK: @owbase/web y @owbase/node

Update a file by its unique ID. Only users with write permissions have access to update this resource.

Parámetro Tipo Obligatorio Descripción
bucketId string sí Bucket unique ID.
fileId string sí File ID.
name string no File name.
permissions string[] no An array of permission strings. By default, the current permissions are inherited. Learn more about permissions.

Acceso: clave de API con el alcance files.write o sesión del usuario, o incluso sin sesión (vale lo que permitan los permisos del recurso).

@owbase/web
import { Client, Storage, Permission, Role } from '@owbase/web';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
const storage = new Storage(client);
const result = await storage.updateFile({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
name: '', // optional
permissions: [Permission.read(Role.any())], // optional
});
console.log(result);
@owbase/node
import { Client, Storage, Permission, Role } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const storage = new Storage(client);
const result = await storage.updateFile({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
name: '', // optional
permissions: [Permission.read(Role.any())], // optional
});

Eliminar archivo

DELETE /storage/buckets/{bucketId}/files/{fileId} · página del método

SDK: @owbase/web y @owbase/node

Delete a file by its unique ID. Only users with write permissions have access to delete this resource.

Parámetro Tipo Obligatorio Descripción
bucketId string sí Storage bucket unique ID. You can create a new storage bucket using the Storage service server integration.
fileId string sí File ID.

Acceso: clave de API con el alcance files.write o sesión del usuario, o incluso sin sesión (vale lo que permitan los permisos del recurso).

@owbase/web
import { Client, Storage } from '@owbase/web';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
const storage = new Storage(client);
const result = await storage.deleteFile({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
});
console.log(result);
@owbase/node
import { Client, Storage } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const storage = new Storage(client);
const result = await storage.deleteFile({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
});

Obtener archivo para descargar

GET /storage/buckets/{bucketId}/files/{fileId}/download · página del método

SDK: @owbase/web y @owbase/node

Get a file content by its unique ID. The endpoint response return with a ‘Content-Disposition: attachment’ header that tells the browser to start downloading the file to user downloads directory.

Parámetro Tipo Obligatorio Descripción
bucketId string sí Storage bucket ID. You can create a new storage bucket using the Storage service server integration.
fileId string sí File ID.
token string no File token for accessing this file.

Acceso: clave de API con el alcance files.read o sesión del usuario, o incluso sin sesión (vale lo que permitan los permisos del recurso).

@owbase/web
import { Client, Storage } from '@owbase/web';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
const storage = new Storage(client);
const result = storage.getFileDownload({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
token: '<TOKEN>', // optional
});
console.log(result);
@owbase/node
import { Client, Storage } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const storage = new Storage(client);
const result = await storage.getFileDownload({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
token: '<TOKEN>', // optional
});

Obtener vista previa del archivo

GET /storage/buckets/{bucketId}/files/{fileId}/preview · página del método

SDK: @owbase/web y @owbase/node

Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. Preview is supported only for image files smaller than 10MB.

Parámetro Tipo Obligatorio Descripción
bucketId string sí Storage bucket unique ID. You can create a new storage bucket using the Storage service server integration.
fileId string sí File ID
width number no Resize preview image width, Pass an integer between 0 to 4000.
height number no Resize preview image height, Pass an integer between 0 to 4000.
gravity ImageGravity no Image crop gravity. Can be one of auto,center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right Valores: auto, center, top-left, top, top-right, left, right, bottom-left, bottom, bottom-right.
quality number no Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.
borderWidth number no Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.
borderColor string no Preview image border color. Use a valid HEX color, no # is needed for prefix.
borderRadius number no Preview image border radius in pixels. Pass an integer between 0 to 4000.
opacity number no Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.
rotation number no Preview image rotation in degrees. Pass an integer between -360 and 360.
background string no Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.
output ImageFormat no Output format type (jpeg, jpg, png, gif and webp). Valores: jpg, jpeg, png, webp, heic, avif, gif.
token string no File token for accessing this file.

Acceso: clave de API con el alcance files.read o sesión del usuario, o incluso sin sesión (vale lo que permitan los permisos del recurso).

@owbase/web
import { Client, Storage, ImageGravity, ImageFormat } from '@owbase/web';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
const storage = new Storage(client);
const result = storage.getFilePreview({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
width: 0, // optional
height: 0, // optional
gravity: ImageGravity.Auto, // optional
quality: -1, // optional
borderWidth: 0, // optional
borderColor: 'FFFFFF', // optional
borderRadius: 0, // optional
opacity: 0, // optional
rotation: -360, // optional
background: 'FFFFFF', // optional
output: ImageFormat.Jpg, // optional
token: '<TOKEN>', // optional
});
console.log(result);
@owbase/node
import { Client, Storage, ImageGravity, ImageFormat } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const storage = new Storage(client);
const result = await storage.getFilePreview({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
width: 0, // optional
height: 0, // optional
gravity: ImageGravity.Auto, // optional
quality: -1, // optional
borderWidth: 0, // optional
borderColor: 'FFFFFF', // optional
borderRadius: 0, // optional
opacity: 0, // optional
rotation: -360, // optional
background: 'FFFFFF', // optional
output: ImageFormat.Jpg, // optional
token: '<TOKEN>', // optional
});

Obtener archivo para ver

GET /storage/buckets/{bucketId}/files/{fileId}/view · página del método

SDK: @owbase/web y @owbase/node

Get a file content by its unique ID. This endpoint is similar to the download method but returns with no ‘Content-Disposition: attachment’ header.

Parámetro Tipo Obligatorio Descripción
bucketId string sí Storage bucket unique ID. You can create a new storage bucket using the Storage service server integration.
fileId string sí File ID.
token string no File token for accessing this file.

Acceso: clave de API con el alcance files.read o sesión del usuario, o incluso sin sesión (vale lo que permitan los permisos del recurso).

@owbase/web
import { Client, Storage } from '@owbase/web';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
const storage = new Storage(client);
const result = storage.getFileView({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
token: '<TOKEN>', // optional
});
console.log(result);
@owbase/node
import { Client, Storage } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const storage = new Storage(client);
const result = await storage.getFileView({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
token: '<TOKEN>', // optional
});

Las descripciones de esta página vienen de la especificación de la API del servidor (licencia BSD-3-Clause), en inglés, y los ejemplos vienen del generador de SDKs (licencia MIT). Los avisos completos están en el archivo NOTICE de los paquetes @owbase/web y @owbase/node.

¿Te ayudó esta página?