Skip to content

POST /storage/upload

Uploads a file (currently supports images) to the project’s storage. Returns a media ID that can be used to link the file to other resources, such as a user avatar.

POST /v1/public/projects/:projectSlug/storage/upload
ParameterTypeRequiredDescription
projectSlugstringYour project’s unique slug
HeaderRequiredDescription
AuthorizationBearer <jwt-token>
Content-Typemultipart/form-data
FieldTypeRequiredDescription
fileFileThe file to upload (Max 5MB, Images only)
{
"id": "725365d7-21fc-45eb-b6ec-8390f0a438d1",
"url": "/v1/public/projects/my-project/storage/725365d7-21fc-45eb-b6ec-8390f0a438d1/file",
"filename": "avatar.jpg",
"mime_type": "image/jpeg",
"size": 177382
}
FieldTypeDescription
idstringImportant: The Media ID. Use this ID to link the file to other resources (e.g., updating user avatar).
urlstringPublic URL to access the file
filenamestringOriginal filename
mime_typestringFile MIME type
sizenumberFile size in bytes
Status CodeError CodeDescription
400BAD_REQUESTNo file uploaded, invalid type, or size limit exceeded
401UNAUTHORIZEDMissing or invalid token
429RATE_LIMIT_EXCEEDEDToo many uploads
const formData = new FormData();
formData.append('file', fileInput.files[0]);
const response = await fetch('https://api.aerostack.dev/v1/public/projects/my-project/storage/upload', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`
// Note: Do NOT set Content-Type header manually when using FormData,
// the browser will set it with the correct boundary.
},
body: formData
});
const data = await response.json();
console.log('Uploaded File ID:', data.id);