Create/upload a new BLOB
Motivation
Creates a new BLOB with the uploaded binary data
Functional design
- POST
/api/v2/apps/{owner}/{app}/workspaces/{wsid}/docs/{pkg}.{table}/blobs/{fieldName}Creates a new BLOB with the uploaded binary data. The ID of the BLOB is returned in the response and can be used to write the BLOB to specified field of a document or record when creating or updating record.
Headers
| Key | Value |
|---|---|
| Authorization | Bearer {PrincipalToken} |
| Content-Type | BLOB content type |
| Blob-Name | BLOB name, optional |
Parameters
| Parameter | Type | Description |
|---|---|---|
| owner | string | name of a user who owns the application |
| app | string | name of an application |
| wsid | int64 | the ID of workspace |
| pkg, table | string | identifies a table (document or record) |
| fieldName | string | name of the field in document which should keep the BLOB |
Body
BLOB data.
Result
| Code | Description | Body |
|---|---|---|
| 201 | Created | blob ID, see example below |
| 400 | Bad Request | error object |
| 401 | Unauthorized | error object |
| 403 | Forbidden | error object |
| 413 | Payload Too Large | error object |
| 415 | Unsupported Media Type | error object |
| 429 | Too Many Requests | error object |
| 500 | Internal Server Error | error object |
| 503 | Service Unavailable | error object |
Example response 201:
{
"blobID": 123456789,
}
Perimssions
- Execution of this function is granted to role
sys.BLOBUploaderwhich is by default granted tosys.WorkspaceOwner.
Technical design
Components
~cmp.sysBlobOwnerRecord~covrd1✅ extend pkg/sys/Workspace/wdoc.sys.BLOB with new fields:OwnerRecord qname NOT NULLOwnerRecordField varchar NOT NULLOwnerRecordID ref
- pkg/router
~cmp.routerBlobsCreatePathHandler~covrd2✅: Create BLOB path handler
- pkg/sys/it
~it.TestBlobsCreate~covrd3✅: integration test for creating BLOBs