Bucket Files Management Endpoints
These endpoints allow you to list, upload, download, and manage files in S3 storage buckets. All operations use a bucket explorer resource ID, which must be connected to a storage bucket via resource connections. Important: The:bucketExplorerId parameter in the URL path is the bucket explorer resource ID, not the storage bucket ID. The system will automatically look up the connected storage bucket via resource connections.
List Files in Bucket
GET /api/:projectSlug/:environmentSlug/storage-buckets/:bucketExplorerId/files- List files and folders in a storage bucket
prefix(optional): Filter files by prefix/folder path (e.g.,"folder/subfolder/")maxKeys(optional): Maximum number of files to return (default: 1000)continuationToken(optional): Token for pagination when previous response was truncated
:bucketExplorerId parameter is the bucket explorer resource ID. Make sure the bucket explorer is connected to a storage bucket via resource connections before using this endpoint.
Example:
Get File Metadata
GET /api/:projectSlug/:environmentSlug/storage-buckets/:bucketExplorerId/files/metadata- Get metadata for a specific file
:bucketExplorerId parameter is the bucket explorer resource ID.
Query Parameters:
key(required): Object key (file path) - e.g.,"folder/file.txt"
1 in the URL is the bucket explorer resource ID, not the storage bucket ID.
Example Response:
Download File
GET /api/:projectSlug/:environmentSlug/storage-buckets/:bucketExplorerId/files/download- Download a file from the storage bucket
:bucketExplorerId parameter is the bucket explorer resource ID.
Query Parameters:
key(required): Object key (file path) - e.g.,"folder/file.txt"
- Returns the file content as a binary stream
- Content-Type header is set based on file type
- Content-Disposition header suggests filename for download
- Content-Length header indicates file size
Upload File
POST /api/:projectSlug/:environmentSlug/storage-buckets/:bucketExplorerId/files/upload- Upload a file to the storage bucket
:bucketExplorerId parameter is the bucket explorer resource ID.
Request:
- Content-Type:
multipart/form-data - Form fields:
file(required): File to uploadkey(optional): Object key (file path). If not provided, uses the original filenamecontentType(optional): Content type. If not provided, auto-detected from file
- Maximum file size: 5GB
- For larger files, consider using AWS S3 direct upload methods
Rename/Move File
PATCH /api/:projectSlug/:environmentSlug/storage-buckets/:bucketExplorerId/files/rename- Rename or move a file in the storage bucket
:bucketExplorerId parameter is the bucket explorer resource ID. In S3, renaming is done by copying the object to a new key and deleting the old one.
Request Body:
- This operation copies the file to the new location and then deletes the old file
- If the destination file already exists, the operation will fail to prevent overwriting
- You can use this endpoint to move files between folders by changing the path in the key
Delete File
DELETE /api/:projectSlug/:environmentSlug/storage-buckets/:bucketExplorerId/files- Delete a single file from the storage bucket
:bucketExplorerId parameter is the bucket explorer resource ID.
Query Parameters:
key(required): Object key (file path) - e.g.,"folder/file.txt"
Delete Multiple Files (Bulk Delete)
DELETE /api/:projectSlug/:environmentSlug/storage-buckets/:bucketExplorerId/files/bulk- Delete multiple files from the storage bucket
:bucketExplorerId parameter is the bucket explorer resource ID.
Request Body:
- Maximum 1000 files per request (AWS S3 limit)
- All keys must be non-empty strings
Folder Structure
S3 uses a flat key-value structure, but you can simulate folders using forward slashes (/) in object keys. For example:
document.pdf- File in rootuploads/document.pdf- File in “uploads” folderuploads/2024/document.pdf- File in nested folder
- Use the
prefixparameter to filter by folder - The
foldersarray in the response shows all prefixes (folders) at the current level - The
filesarray shows actual files at the current level
Pagination
When listing files in large buckets, responses may be truncated. Use pagination to retrieve all files:Error Responses
File Not Found (404):Notes
- All file operations require authentication
- The
:bucketExplorerIdparameter is the bucket explorer resource ID, not the storage bucket ID - The bucket explorer must be connected to a storage bucket via resource connections before using these endpoints
- Users can only access files in buckets they own
- File uploads are limited to 5GB per file
- File paths (keys) are case-sensitive
- Deleting a file is permanent and cannot be undone (unless versioning is enabled)
- The API automatically handles AWS credential management using AssumeRole
- If a bucket explorer is not connected to a storage bucket, these endpoints will return an error