Read/download the BLOB
Motivation
Retrieve the BLOB from the field of a document or record, using API
Functional design
GET /api/v2/apps/{owner}/{app}/workspaces/{wsid}/docs/{pkg}.{table}/{id}/blobs/{fieldName}
Headers / Cookies
Authorization is supported via Bearer token. The token can be passed in the Authorization header or as a cookie. The token is obtained during the authentication process.
| Key | Value | Description |
|---|---|---|
| Authorization | Bearer {PrincipalToken} | The token obtained during the authentication process |
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) |
| id | int64 | ID of a document or record |
| fieldName | string | name of the field containing the BLOB |
Response Headers
| Key | Value | Description |
|---|---|---|
| Content-Type | BLOB metadata | Returns the originally provided metadata |
| Blob-Name | BLOB name | Returns the originally provided name |
Result
| Code | Description | Body |
|---|---|---|
| 200 | OK | BLOB binary data |
| 400 | Bad Request | error object |
| 401 | Unauthorized | error object |
| 403 | Forbidden | error object |
| 404 | Not Found | error object |
| 429 | Too Many Requests | error object |
| 500 | Internal Server Error | error object |
| 503 | Service Unavailable | error object |
Technical design
Schema
Components
-
pkg/router
- API v2 URL path handler
~cmp.routerBlobsReadPathHandler~covrd1✅:
- API v2 URL path handler
-
pkg/processors/blobber
- BLOB request handler :
- Provide BLOB processor, which handles read and write operations for BLOBs
~cmp.blobber.ProvideService~covrd4✅ - Sync Pipeline of the BLOB processor
~cmp.blobber.ServicePipeline~covrd5✅- operator getBLOBMessageRead
~cmp.blobber.ServicePipeline_getBLOBMessageRead~covrd6✅ - operator getBLOBIDFromOwner
~cmp.blobber.ServicePipeline_getBLOBIDFromOwner~covrd7✅- for APIv2: gets BLOB ID from the owner by fieldname by sending request to QPv2 to bus and verifies the access rights
- operator getBLOBKeyRead
~cmp.blobber.ServicePipeline_getBLOBKeyRead~covrd8✅- creates BLOB key for reading
- queryBLOBState
~cmp.blobber.ServicePipeline_queryBLOBState~covrd9✅- reads and verifies BLOB state from
iblobstoragestg
- reads and verifies BLOB state from
- downloadBLOBHelper
~cmp.blobber.ServicePipeline_downloadBLOBHelper~covrd10✅- for APIv1: verifies token by executing
q.sys.DownloadBLOBAuthnz
- for APIv1: verifies token by executing
- initResponse
~cmp.blobber.ServicePipeline_initResponse~covrd11✅- init response with BLOB name and content type
- readBLOB
~cmp.blobber.ServicePipeline_readBLOB~covrd12✅- reads BLOB from
iblobstoragestgand writes it to the response
- reads BLOB from
- catchReadError
~cmp.blobber.ServicePipeline_catchReadError~covrd13✅- handles errors
- operator getBLOBMessageRead
-
pkg/sys/it
- integration test for reading BLOBs
~it.TestBlobsRead~covrd14✅
- integration test for reading BLOBs