Skip to main content

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.

KeyValueDescription
AuthorizationBearer {PrincipalToken}The token obtained during the authentication process

Parameters​

ParameterTypeDescription
ownerstringname of a user who owns the application
appstringname of an application
wsidint64the ID of workspace
pkg, tablestringidentifies a table (document or record)
idint64ID of a document or record
fieldNamestringname of the field containing the BLOB

Response Headers​

KeyValueDescription
Content-TypeBLOB metadataReturns the originally provided metadata
Blob-NameBLOB nameReturns the originally provided name
Content-LengthBLOB sizeReturns the BLOB size in bytes

Result​

CodeDescriptionBody
200OKBLOB binary data
400Bad Requesterror object
401Unauthorizederror object
403Forbiddenerror object
404Not Founderror object
429Too Many Requestserror object
500Internal Server Errorerror object
503Service Unavailableerror object

Technical design​

Schema​

Components​

  • pkg/router

    • API v2 URL path handler ~cmp.routerBlobsReadPathHandler~covrd1✅:
  • pkg/processors/blobber

    • BLOB request handler :
      • interface ~cmp.blobber.IRequestHandler~covrd2✅
      • implementation: read handler for APIv2, sends messages to the bus ~cmp.blobber.implIRequestHandler_Read2~covrd3✅
    • 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
      • downloadBLOBHelper ~cmp.blobber.ServicePipeline_downloadBLOBHelper~covrd10✅
        • for APIv1: verifies token by executing q.sys.DownloadBLOBAuthnz
      • initResponse ~cmp.blobber.ServicePipeline_initResponse~covrd11✅
        • init response with BLOB name and content type
      • readBLOB ~cmp.blobber.ServicePipeline_readBLOB~covrd12✅
        • reads BLOB from iblobstoragestg and writes it to the response
      • catchReadError ~cmp.blobber.ServicePipeline_catchReadError~covrd13✅
        • handles errors
  • pkg/sys/it

    • integration test for reading BLOBs
      • ~it.TestBlobsRead~covrd14✅

Footnotes​

  1. [~server.apiv2.blobs/cmp.routerBlobsReadPathHandler~impl] pkg/router/impl_apiv2.go:134:impl ↩

  2. [~server.apiv2.blobs/cmp.blobber.IRequestHandler~impl] pkg/processors/blobber/interface.go:19:impl ↩

  3. [~server.apiv2.blobs/cmp.blobber.implIRequestHandler_Read2~impl] pkg/processors/blobber/impl_requesthandler.go:38:impl ↩

  4. [~server.apiv2.blobs/cmp.blobber.ProvideService~impl] pkg/processors/blobber/provide.go:17:impl ↩

  5. [~server.apiv2.blobs/cmp.blobber.ServicePipeline~impl] pkg/processors/blobber/impl.go:15:impl ↩

  6. [~server.apiv2.blobs/cmp.blobber.ServicePipeline_getBLOBMessageRead~impl] pkg/processors/blobber/impl.go:21:impl, pkg/processors/blobber/impl_read.go:164:impl ↩

  7. [~server.apiv2.blobs/cmp.blobber.ServicePipeline_getBLOBIDFromOwner~impl] pkg/processors/blobber/impl.go:22:impl, pkg/processors/blobber/impl_read.go:122:impl ↩

  8. [~server.apiv2.blobs/cmp.blobber.ServicePipeline_getBLOBKeyRead~impl] pkg/processors/blobber/impl.go:23:impl, pkg/processors/blobber/impl_read.go:26:impl ↩

  9. [~server.apiv2.blobs/cmp.blobber.ServicePipeline_queryBLOBState~impl] pkg/processors/blobber/impl.go:24:impl, pkg/processors/blobber/impl_read.go:64:impl ↩

  10. [~server.apiv2.blobs/cmp.blobber.ServicePipeline_downloadBLOBHelper~impl] pkg/processors/blobber/impl.go:25:impl, pkg/processors/blobber/impl_read.go:85:impl ↩

  11. [~server.apiv2.blobs/cmp.blobber.ServicePipeline_initResponse~impl] pkg/processors/blobber/impl.go:26:impl, pkg/processors/blobber/impl_read.go:54:impl ↩

  12. [~server.apiv2.blobs/cmp.blobber.ServicePipeline_readBLOB~impl] pkg/processors/blobber/impl.go:27:impl, pkg/processors/blobber/impl_read.go:109:impl ↩

  13. [~server.apiv2.blobs/cmp.blobber.ServicePipeline_catchReadError~impl] pkg/processors/blobber/impl.go:28:impl, pkg/processors/blobber/types.go:93:impl ↩

  14. [~server.apiv2.blobs/it.TestBlobsRead~impl] pkg/sys/it/impl_blob_test.go:73:impl ↩