StorageBucket
Constructors
Section titled “Constructors”new StorageBucket()
Section titled “new StorageBucket()”new StorageBucket(
fetch,bucketName):StorageBucket
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
fetch | FluxbaseFetch |
bucketName | string |
Returns
Section titled “Returns”Methods
Section titled “Methods”abortResumableUpload()
Section titled “abortResumableUpload()”abortResumableUpload(
sessionId):Promise<object>
Abort an in-progress resumable upload
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
sessionId | string | The upload session ID to abort |
Returns
Section titled “Returns”Promise<object>
| Name | Type |
|---|---|
error | null | Error |
copy()
Section titled “copy()”copy(
fromPath,toPath):Promise<object>
Copy a file to a new location
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
fromPath | string | Source file path |
toPath | string | Destination file path |
Returns
Section titled “Returns”Promise<object>
| Name | Type |
|---|---|
data | null | object |
error | null | Error |
createSignedUrl()
Section titled “createSignedUrl()”createSignedUrl(
path,options?):Promise<object>
Create a signed URL for temporary access to a file Optionally include image transformation parameters
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | string | The file path |
options? | SignedUrlOptions | Signed URL options including expiration and transforms |
Returns
Section titled “Returns”Promise<object>
| Name | Type |
|---|---|
data | null | object |
error | null | Error |
Example
Section titled “Example”// Simple signed URL (1 hour expiry)const { data, error } = await storage.from('images').createSignedUrl('photo.jpg');
// Signed URL with custom expiryconst { data, error } = await storage.from('images').createSignedUrl('photo.jpg', { expiresIn: 7200 // 2 hours});
// Signed URL with image transformationconst { data, error } = await storage.from('images').createSignedUrl('photo.jpg', { expiresIn: 3600, transform: { width: 400, height: 300, format: 'webp', quality: 85, fit: 'cover' }});download()
Section titled “download()”download(path)
Section titled “download(path)”download(
path):Promise<object>
Download a file from the bucket
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | string | The path/key of the file |
Returns
Section titled “Returns”Promise<object>
| Name | Type |
|---|---|
data | null | Blob |
error | null | Error |
Example
Section titled “Example”// Default: returns Blobconst { data: blob } = await storage.from('bucket').download('file.pdf');
// Streaming: returns { stream, size } for progress trackingconst { data } = await storage.from('bucket').download('large.json', { stream: true });console.log(`File size: ${data.size} bytes`);// Process data.stream...download(path, options)
Section titled “download(path, options)”download(
path,options):Promise<object>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path | string |
options | object |
options.signal? | AbortSignal |
options.stream | true |
options.timeout? | number |
Returns
Section titled “Returns”Promise<object>
| Name | Type |
|---|---|
data | null | StreamDownloadData |
error | null | Error |
download(path, options)
Section titled “download(path, options)”download(
path,options):Promise<object>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path | string |
options | object |
options.signal? | AbortSignal |
options.stream? | false |
options.timeout? | number |
Returns
Section titled “Returns”Promise<object>
| Name | Type |
|---|---|
data | null | Blob |
error | null | Error |
downloadResumable()
Section titled “downloadResumable()”downloadResumable(
path,options?):Promise<object>
Download a file with resumable chunked downloads for large files. Returns a ReadableStream that abstracts the chunking internally.
Features:
- Downloads file in chunks using HTTP Range headers
- Automatically retries failed chunks with exponential backoff
- Reports progress via callback
- Falls back to regular streaming if Range not supported
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | string | The file path within the bucket |
options? | ResumableDownloadOptions | Download options including chunk size, retries, and progress callback |
Returns
Section titled “Returns”Promise<object>
A ReadableStream and file size (consumer doesn’t need to know about chunking)
| Name | Type |
|---|---|
data | null | ResumableDownloadData |
error | null | Error |
Example
Section titled “Example”const { data, error } = await storage.from('bucket').downloadResumable('large.json', { chunkSize: 5 * 1024 * 1024, // 5MB chunks maxRetries: 3, onProgress: (progress) => console.log(`${progress.percentage}% complete`)});if (data) { console.log(`File size: ${data.size} bytes`); // Process data.stream...}getPublicUrl()
Section titled “getPublicUrl()”getPublicUrl(
path):object
Get a public URL for a file
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | string | The file path |
Returns
Section titled “Returns”object
| Name | Type |
|---|---|
data | object |
data.publicUrl | string |
getResumableUploadStatus()
Section titled “getResumableUploadStatus()”getResumableUploadStatus(
sessionId):Promise<object>
Get the status of a resumable upload session
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
sessionId | string | The upload session ID to check |
Returns
Section titled “Returns”Promise<object>
| Name | Type |
|---|---|
data | null | ChunkedUploadSession |
error | null | Error |
getTransformUrl()
Section titled “getTransformUrl()”getTransformUrl(
path,transform):string
Get a public URL for a file with image transformations applied Only works for image files (JPEG, PNG, WebP, GIF, AVIF, etc.)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | string | The file path |
transform | TransformOptions | Transformation options (width, height, format, quality, fit) |
Returns
Section titled “Returns”string
Example
Section titled “Example”// Get a 300x200 WebP thumbnailconst url = storage.from('images').getTransformUrl('photo.jpg', { width: 300, height: 200, format: 'webp', quality: 85, fit: 'cover'});
// Get a resized image maintaining aspect ratioconst url = storage.from('images').getTransformUrl('photo.jpg', { width: 800, format: 'webp'});list()
Section titled “list()”list(
pathOrOptions?,maybeOptions?):Promise<object>
List files in the bucket Supports both Supabase-style list(path, options) and Fluxbase-style list(options)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
pathOrOptions? | string | ListOptions | The folder path or list options |
maybeOptions? | ListOptions | List options when first param is a path |
Returns
Section titled “Returns”Promise<object>
| Name | Type |
|---|---|
data | null | FileObject[] |
error | null | Error |
listShares()
Section titled “listShares()”listShares(
path):Promise<object>
List users a file is shared with (RLS)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | string | The file path |
Returns
Section titled “Returns”Promise<object>
| Name | Type |
|---|---|
data | null | FileShare[] |
error | null | Error |
move()
Section titled “move()”move(
fromPath,toPath):Promise<object>
Move a file to a new location
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
fromPath | string | Current file path |
toPath | string | New file path |
Returns
Section titled “Returns”Promise<object>
| Name | Type |
|---|---|
data | null | object |
error | null | Error |
remove()
Section titled “remove()”remove(
paths):Promise<object>
Remove files from the bucket
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
paths | string[] | Array of file paths to remove |
Returns
Section titled “Returns”Promise<object>
| Name | Type |
|---|---|
data | null | FileObject[] |
error | null | Error |
revokeShare()
Section titled “revokeShare()”revokeShare(
path,userId):Promise<object>
Revoke file access from a user (RLS)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | string | The file path |
userId | string | The user ID to revoke access from |
Returns
Section titled “Returns”Promise<object>
| Name | Type |
|---|---|
data | null |
error | null | Error |
share()
Section titled “share()”share(
path,options):Promise<object>
Share a file with another user (RLS)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | string | The file path |
options | ShareFileOptions | Share options (userId and permission) |
Returns
Section titled “Returns”Promise<object>
| Name | Type |
|---|---|
data | null |
error | null | Error |
upload()
Section titled “upload()”upload(
path,file,options?):Promise<object>
Upload a file to the bucket
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | string | The path/key for the file |
file | Blob | ArrayBufferView | ArrayBuffer | File | The file to upload (File, Blob, ArrayBuffer, or ArrayBufferView like Uint8Array) |
options? | UploadOptions | Upload options |
Returns
Section titled “Returns”Promise<object>
| Name | Type |
|---|---|
data | null | object |
error | null | Error |
uploadLargeFile()
Section titled “uploadLargeFile()”uploadLargeFile(
path,file,options?):Promise<object>
Upload a large file using streaming for reduced memory usage. This is a convenience method that converts a File or Blob to a stream.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | string | The path/key for the file |
file | Blob | File | The File or Blob to upload |
options? | StreamUploadOptions | Upload options |
Returns
Section titled “Returns”Promise<object>
| Name | Type |
|---|---|
data | null | object |
error | null | Error |
Example
Section titled “Example”const file = new File([...], 'large-video.mp4');const { data, error } = await storage .from('videos') .uploadLargeFile('video.mp4', file, { contentType: 'video/mp4', onUploadProgress: (p) => console.log(`${p.percentage}% complete`), });uploadResumable()
Section titled “uploadResumable()”uploadResumable(
path,file,options?):Promise<object>
Upload a large file with resumable chunked uploads.
Features:
- Uploads file in chunks for reliability
- Automatically retries failed chunks with exponential backoff
- Reports progress via callback with chunk-level granularity
- Can resume interrupted uploads using session ID
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | string | The file path within the bucket |
file | Blob | File | The File or Blob to upload |
options? | ResumableUploadOptions | Upload options including chunk size, retries, and progress callback |
Returns
Section titled “Returns”Promise<object>
Upload result with file info
| Name | Type |
|---|---|
data | null | object |
error | null | Error |
Example
Section titled “Example”const { data, error } = await storage.from('uploads').uploadResumable('large.zip', file, { chunkSize: 5 * 1024 * 1024, // 5MB chunks maxRetries: 3, onProgress: (p) => { console.log(`${p.percentage}% (chunk ${p.currentChunk}/${p.totalChunks})`); console.log(`Speed: ${(p.bytesPerSecond / 1024 / 1024).toFixed(2)} MB/s`); console.log(`Session ID (for resume): ${p.sessionId}`); }});
// To resume an interrupted upload:const { data, error } = await storage.from('uploads').uploadResumable('large.zip', file, { resumeSessionId: 'previous-session-id',});uploadStream()
Section titled “uploadStream()”uploadStream(
path,stream,size,options?):Promise<object>
Upload a file using streaming for reduced memory usage. This method bypasses FormData buffering and streams data directly to the server. Ideal for large files where memory efficiency is important.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | string | The path/key for the file |
stream | ReadableStream<Uint8Array> | ReadableStream of the file data |
size | number | The size of the file in bytes (required for Content-Length header) |
options? | StreamUploadOptions | Upload options |
Returns
Section titled “Returns”Promise<object>
| Name | Type |
|---|---|
data | null | object |
error | null | Error |
Example
Section titled “Example”// Upload from a File's streamconst file = new File([...], 'large-video.mp4');const { data, error } = await storage .from('videos') .uploadStream('video.mp4', file.stream(), file.size, { contentType: 'video/mp4', });
// Upload from a fetch response streamconst response = await fetch('https://example.com/data.zip');const size = parseInt(response.headers.get('content-length') || '0');const { data, error } = await storage .from('files') .uploadStream('data.zip', response.body!, size, { contentType: 'application/zip', });