Cloud Storage (Files)
Suppa API integrates with Google Cloud Storage (GCS) for file management. The process involves getting a pre-signed upload URL and then "attaching" the uploaded file to a specific entity record.
Uploading a File
The unified upload API simplifies the process by combining file upload and attachment into a single request.
Endpoint: POST /core/files/upload
Request Body (form-data)
The request should be sent as multipart/form-data with two primary fields:
meta(String/JSON): A JSON string containing the attachment metadata.file(File): The binary content of the file.
Meta Field Structure
| Field | Type | Required | Description |
|---|---|---|---|
entityName | string | true | Entity type (e.g., Products, Receipts). |
recordId | number | true | The ID of the specific record to attach the file to. |
entityFieldName | string | true | The field name in the entity where the file should be attached. |
Response Body
The response is an object containing arrays for successful and failed uploads, along with a summary.
{
"success": [
{
"id": 123,
"fileName": "document.pdf",
"downloadUrl": "https://storage.googleapis.com/...",
"createdAt": "2023-10-27T10:00:00Z"
}
],
"errors": [],
"summary": {
"total": 1,
"successful": 1,
"failed": 0
}
}Success Object Fields
| Field | Type | Description |
|---|---|---|
id | number | ID of the created record in the files table. |
fileName | string | The name of the uploaded file. |
downloadUrl | string | Direct URL to download the file. |
createdAt | string | ISO timestamp of creation. |
Downloading a File
Directly download file content using its unique identifier.
Endpoint: GET /core/files/download
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
fileId | string | true | The unique identifier of the file to download. |
fileType | string | true | The type of file (e.g., file, preview). |
Response
The response body contains the binary content of the file.
Remove Files
Delete one or more files from the system.
Endpoint: POST /core/data/Files/remove
Request Body:
{
"conditions": {
"operator": "and",
"filters": [
{
"field": "id",
"comparator": "in",
"value": [10, 11]
}
]
}
}