/storage/bucketsAlcance buckets.writeSDK: solo @owbase/node
Create a new storage bucket.
Parámetros
Sección titulada «Parámetros»bucketId string obligatorio
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 obligatorio
Bucket name
permissions string[]
An array of permission strings. By default, no user is granted with any permissions. Learn more about permissions.
fileSecurity boolean
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
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
Maximum file size allowed in bytes. Maximum allowed value is 0B.
allowedFileExtensions string[]
Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.
compression Compression
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
Is encryption enabled? For file size above 20MB encryption is skipped even if it’s enabled
antivirus boolean
Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it’s enabled
transformations boolean
Are image transformations enabled?
description string
Optional description for the bucket.
stripMetadata boolean
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.
Respuestas
Sección titulada «Respuestas»201Éxito400Parámetro inválido o faltante401Sin sesión, sin permiso en el recurso o clave sin el alcance429Límite de peticionesTodo error llega como JSON con code, type y message: consulta Errores.
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});curl -X POST "https://cloud.owbase.dev/v1/storage/buckets" \ -H "X-Owbase-Project: <PROJECT_ID>" \ -H "X-Owbase-Key: $OWBASE_API_KEY" \ -H "Content-Type: application/json" \ -d '{"bucketId":"<BUCKET_ID>","name":"<NAME>"}'{ "$id": "5e5ea5c16897e", "$createdAt": "2020-10-15T06:38:00.000+00:00", "$updatedAt": "2020-10-15T06:38:00.000+00:00", "$permissions": [ "read(\"any\")" ], "fileSecurity": true, "name": "Documents", "description": "Invoices and receipts uploaded by customers.", "enabled": false, "maximumFileSize": 100, "allowedFileExtensions": [ "jpg", "png" ], "compression": "gzip", "encryption": false, "antivirus": false, "transformations": false, "stripMetadata": true, "totalSize": 128}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.