API Endpoint
Esta página aún no está disponible en tu idioma.
The Storage API exposes endpoints that can be accessed via HTTP requests. The following sections describe the available endpoints and their usage.
The Storage API endpoints make use of the Astro locals feature propagated by Middleware to handle authorization. Ensure that the browser or client making the requests is coming from a logged-in StudioCMS user with the appropriate permissions to perform storage operations.
Method: PUT
Section titled “Method: PUT”To upload or update a file in the storage system, you can use the PUT method on the /studiocms_api/storage/manager endpoint.
PUT /studiocms_api/storage/manager HTTP/1.1Host: example.comContent-Type: application/octet-streamAccept: application/jsonHeaders: x-storage-key: my-file.txt
<file-content>Successful Response
Section titled “Successful Response”HTTP/1.1 200 OKContent-Type: application/json
{ "message": "string", "key": "string"}Error Response
Section titled “Error Response”HTTP/1.1 4XX/5XX ErrorContent-Type: application/json
{ "error": "string"}Method: POST
Section titled “Method: POST”POST /studiocms_api/storage/manager HTTP/1.1Host: example.comContent-Type: application/jsonAccept: application/json
{ "action": "resolveUrl | publicUrl | upload | list | delete | rename | download | cleanup | mappings | test", ...additional parameters based on action...}Actions
Section titled “Actions”resolveUrl- Params:
{ identifier: string } - Response:
UrlMetadata
- Params:
publicUrl- Params:
{ key: string } - Response:
UrlMetadata& { identifier: string }
- Params:
upload- Params:
{ key: string, contentType: string } - Response:
{ url: string, key: string }
- Params:
list- Params:
{ prefix?: string, key?: string } - Response:
{ files:File[]}
- Params:
delete- Params:
{ key: string } - Response:
{ success: boolean }
- Params:
rename- Params:
{ key: string, newKey: string } - Response:
{ success: boolean, newKey: string }
- Params:
download- Params:
{ key: string } - Response:
{ url: string }
- Params:
cleanup- Params:
N/A - Response:
{ deletedCount: number }
- Params:
mappings- Params:
N/A - Response:
{ mappings:UrlMetadata[]}
- Params:
test- Params:
N/A - Response:
{ success: boolean, message: string, provider: string }
- Params:
Error Response
Section titled “Error Response”HTTP/1.1 4XX/5XX ErrorContent-Type: application/json
{ "error": "string"}UrlMetadata
Section titled “UrlMetadata”export interface UrlMetadata { url: string; isPermanent: boolean; expiresAt?: number; // Unix timestamp in ms}export interface File { key: string | undefined; size: number | undefined; lastModified: Date | undefined;}