Start uploading a file
const url = 'https://example.com/v1/example/files';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"contentType":"image/webp","size":1,"path":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/v1/example/files \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "contentType": "image/webp", "size": 1, "path": "example" }'Gives a presigned upload to the file store. Upload the file by POSTing a multipart/form-data form to upload.url: every field in upload.fields, then the file as file, last. Then call /files/complete with the uploadId to add the file to the space. The upload expires after an hour.
The store only takes the file at the type given, and no bigger than size. Types, and how big they can be: image/webp 25MB, image/png 25MB, image/jpeg 25MB, image/gif 25MB, audio/mpeg 50MB, audio/mp4 50MB, audio/aac 50MB, audio/ogg 50MB, audio/wav 50MB, model/gltf-binary 500MB, model/gltf+json 500MB, application/octet-stream 500MB, application/json 50MB.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The project ID of the space
Request Bodyrequired
Section titled “Request Bodyrequired”object
The file’s size in bytes.
The path to give the file, e.g. /entities/desk/banner.webp. Defaults to one under /uploads/. A file already at the path is replaced.
Responses
Section titled “Responses”The upload
object
Identifies the upload, for /files/complete.
object
object
When the upload expires, in milliseconds since the Unix epoch.
Example generated
{ "uploadId": "example", "path": "example", "upload": { "url": "example", "fields": { "additionalProperty": "example" } }, "expiresAt": 1}The body is invalid. issues describes what was wrong.
object
A description of the error
A stable identifier for the kind of error
For invalidBody: what failed validation, and where
object
Example generated
{ "error": "example", "code": "example", "issues": [ {} ]}The token is missing or invalid.
object
A description of the error
A stable identifier for the kind of error
For invalidBody: what failed validation, and where
object
Example generated
{ "error": "example", "code": "example", "issues": [ {} ]}The token has no access to this space.
object
A description of the error
A stable identifier for the kind of error
For invalidBody: what failed validation, and where
object
Example generated
{ "error": "example", "code": "example", "issues": [ {} ]}The file is bigger than its type allows (tooLarge)
object
A description of the error
A stable identifier for the kind of error
For invalidBody: what failed validation, and where
object
Example generated
{ "error": "example", "code": "example", "issues": [ {} ]}Too many requests. Retry after Retry-After seconds.
object
A description of the error
A stable identifier for the kind of error
For invalidBody: what failed validation, and where
object
Example generated
{ "error": "example", "code": "example", "issues": [ {} ]}Headers
Section titled “Headers”Seconds to wait before retrying
Something upstream failed.
object
A description of the error
A stable identifier for the kind of error
For invalidBody: what failed validation, and where
object
Example generated
{ "error": "example", "code": "example", "issues": [ {} ]}The space is moving between servers. Retry after Retry-After seconds.
object
A description of the error
A stable identifier for the kind of error
For invalidBody: what failed validation, and where
object
Example generated
{ "error": "example", "code": "example", "issues": [ {} ]}Headers
Section titled “Headers”Seconds to wait before retrying
Something upstream timed out.
object
A description of the error
A stable identifier for the kind of error
For invalidBody: what failed validation, and where
object
Example generated
{ "error": "example", "code": "example", "issues": [ {} ]}