/storage/buckets/{bucketId}/filesAlcance files.writeCreate 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ámetros
Sección titulada «Parámetros»bucketId string obligatorio
Storage bucket unique ID. You can create a new storage bucket using the Storage service server integration.
fileId string obligatorio
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 obligatorio
Binary file. Owbase SDKs provide helpers to handle file input. Learn about file input.
permissions string[]
An array of permission strings. By default, only the current user is granted all permissions. Learn more about permissions.
folder string
Virtual folder to place the file in, for example “photos/2026”. Nest folders with /. Defaults to the bucket root.
onProgress (progress: UploadProgress) => void
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).
Respuestas
Sección titulada «Respuestas»201Éxito400Parámetro inválido o faltante401Sin sesión, sin permiso en el recurso o clave sin el alcance404Recurso de la ruta no encontrado429Límite de peticionesTodo error llega como JSON con code, type y message: consulta Errores.
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);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});curl -X POST "https://cloud.owbase.dev/v1/storage/buckets/<BUCKET_ID>/files" \ -H "X-Owbase-Project: <PROJECT_ID>" \ -H "X-Owbase-Key: $OWBASE_API_KEY" \ -F "fileId=<FILE_ID>" \{ "$id": "5e5ea5c16897e", "bucketId": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", "$updatedAt": "2020-10-15T06:38:00.000+00:00", "$permissions": [ "read(\"any\")" ], "name": "Pink.png", "folder": "photos/2026/", "key": "photos/2026/Pink.png", "signature": "5d529fd02b544198ae075bd57c1762bb", "mimeType": "image/png", "sizeOriginal": 17890, "sizeActual": 12345, "chunksTotal": 17890, "chunksUploaded": 17890, "encryption": true, "compression": "gzip"}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.