/storage/buckets/{bucketId}/files/{fileId}/previewAlcance files.readGet 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á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
width number
Resize preview image width, Pass an integer between 0 to 4000.
height number
Resize preview image height, Pass an integer between 0 to 4000.
gravity ImageGravity
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
Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.
borderWidth number
Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.
borderColor string
Preview image border color. Use a valid HEX color, no # is needed for prefix.
borderRadius number
Preview image border radius in pixels. Pass an integer between 0 to 4000.
opacity number
Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.
rotation number
Preview image rotation in degrees. Pass an integer between -360 and 360.
background string
Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.
output ImageFormat
Output format type (jpeg, jpg, png, gif and webp). Valores: jpg, jpeg, png, webp, heic, avif, gif.
token string
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).
Respuestas
Sección titulada «Respuestas»200É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, 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);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});curl "https://cloud.owbase.dev/v1/storage/buckets/<BUCKET_ID>/files/<FILE_ID>/preview" \ -H "X-Owbase-Project: <PROJECT_ID>" \ -H "X-Owbase-Key: $OWBASE_API_KEY"Sin cuerpo en la respuesta.
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.