Skip to main content

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
Query Parameters:
  • 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
Note: The :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:
Example Response:

Get File Metadata

  • GET /api/:projectSlug/:environmentSlug/storage-buckets/:bucketExplorerId/files/metadata - Get metadata for a specific file
Note: The :bucketExplorerId parameter is the bucket explorer resource ID. Query Parameters:
  • key (required): Object key (file path) - e.g., "folder/file.txt"
Example:
Note: The 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
Note: The :bucketExplorerId parameter is the bucket explorer resource ID. Query Parameters:
  • key (required): Object key (file path) - e.g., "folder/file.txt"
Example:
Response:
  • 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
Note: The :bucketExplorerId parameter is the bucket explorer resource ID. Request:
  • Content-Type: multipart/form-data
  • Form fields:
    • file (required): File to upload
    • key (optional): Object key (file path). If not provided, uses the original filename
    • contentType (optional): Content type. If not provided, auto-detected from file
Example using curl:
Example using JavaScript (FormData):
Example Response:
File Size Limits:
  • 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
Note: The :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:
Example:
Example (move to different folder):
Example Response:
Error Response (file not found):
Error Response (destination file exists):
Error Response (same key):
Note:
  • 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
Note: The :bucketExplorerId parameter is the bucket explorer resource ID. Query Parameters:
  • key (required): Object key (file path) - e.g., "folder/file.txt"
Example:
Example Response:
Error Response (file not found):

Delete Multiple Files (Bulk Delete)

  • DELETE /api/:projectSlug/:environmentSlug/storage-buckets/:bucketExplorerId/files/bulk - Delete multiple files from the storage bucket
Note: The :bucketExplorerId parameter is the bucket explorer resource ID. Request Body:
Limits:
  • Maximum 1000 files per request (AWS S3 limit)
  • All keys must be non-empty strings
Example:
Example Response (all successful):
Example Response (partial success):
Error Responses: Empty keys array:
Too many keys:
Invalid keys:

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 root
  • uploads/document.pdf - File in “uploads” folder
  • uploads/2024/document.pdf - File in nested folder
When listing files:
  • Use the prefix parameter to filter by folder
  • The folders array in the response shows all prefixes (folders) at the current level
  • The files array shows actual files at the current level
Example: List files in a folder

Pagination

When listing files in large buckets, responses may be truncated. Use pagination to retrieve all files:

Error Responses

File Not Found (404):
Access Denied (403):
Bucket Not Found (404):
File Too Large (400):

Notes

  • All file operations require authentication
  • The :bucketExplorerId parameter 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
Error Response (bucket explorer not connected):