Skip to main content
Module

x/appwrite/mod.ts>Storage

[READ-ONLY] Official Appwrite Deno SDK 🦕
Latest
class Storage
extends Service
Re-export
import { Storage } from "https://deno.land/x/appwrite@10.0.0/mod.ts";

Constructors

new
Storage(client: Client)

Methods

createBucket(
bucketId: string,
name: string,
permissions?: string[],
fileSecurity?: boolean,
enabled?: boolean,
maximumFileSize?: number,
allowedFileExtensions?: string[],
compression?: Compression,
encryption?: boolean,
antivirus?: boolean,
): Promise<Models.Bucket>

Create bucket

Create a new storage bucket.

createFile(
bucketId: string,
fileId: string,
file: InputFile,
permissions?: string[],
onProgress?,
): Promise<Models.File>

Create file

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 Appwrite 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-appwrite-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 Appwrite SDKs, all the chunking logic will be managed by the SDK internally.

deleteBucket(bucketId: string): Promise<Response>

Delete bucket

Delete a storage bucket by its unique ID.

deleteFile(bucketId: string, fileId: string): Promise<Response>

Delete File

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

getBucket(bucketId: string): Promise<Models.Bucket>

Get bucket

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

getFile(bucketId: string, fileId: string): Promise<Models.File>

Get file

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

getFileDownload(bucketId: string, fileId: string): Promise<ArrayBuffer>

Get file for download

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.

getFilePreview(
bucketId: string,
fileId: string,
width?: number,
height?: number,
gravity?: ImageGravity,
quality?: number,
borderWidth?: number,
borderColor?: string,
borderRadius?: number,
opacity?: number,
rotation?: number,
background?: string,
output?: ImageFormat,
): Promise<ArrayBuffer>

Get file preview

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.

getFileView(bucketId: string, fileId: string): Promise<ArrayBuffer>

Get file for view

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

listBuckets(queries?: string[], search?: string): Promise<Models.BucketList>

List buckets

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

listFiles(
bucketId: string,
queries?: string[],
search?: string,
): Promise<Models.FileList>

List files

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

updateBucket(
bucketId: string,
name: string,
permissions?: string[],
fileSecurity?: boolean,
enabled?: boolean,
maximumFileSize?: number,
allowedFileExtensions?: string[],
compression?: Compression,
encryption?: boolean,
antivirus?: boolean,
): Promise<Models.Bucket>

Update bucket

Update a storage bucket by its unique ID.

updateFile(
bucketId: string,
fileId: string,
name?: string,
permissions?: string[],
): Promise<Models.File>

Update file

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