Skip to main content

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

KeyValue
AuthorizationBearer {PrincipalToken}
Content-TypeBLOB content type
Blob-NameBLOB name, optional

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)
fieldNamestringname of the field in document which should keep the BLOB

Body

BLOB data.

Result

CodeDescriptionBody
201Createdblob ID, see example below
400Bad Requesterror object
401Unauthorizederror object
403Forbiddenerror object
413Payload Too Largeerror object
415Unsupported Media Typeerror object
429Too Many Requestserror object
500Internal Server Errorerror object
503Service Unavailableerror object

Example response 201:

{
"blobID": 123456789,
}

Perimssions

  • Execution of this function is granted to role sys.BLOBUploader which is by default granted to sys.WorkspaceOwner.

Technical design

Components

  • ~cmp.sysBlobOwnerRecord~covrd1✅ extend pkg/sys/Workspace/wdoc.sys.BLOB with new fields:
    • OwnerRecord qname NOT NULL
    • OwnerRecordField varchar NOT NULL
    • OwnerRecordID ref
  • pkg/router
    • ~cmp.routerBlobsCreatePathHandler~covrd2✅: Create BLOB path handler
  • pkg/sys/it
    • ~it.TestBlobsCreate~covrd3✅: integration test for creating BLOBs

Footnotes

  1. [~server.apiv2.blobs/cmp.sysBlobOwnerRecord~impl] pkg/sys/sys.vsql:67:impl

  2. [~server.apiv2.blobs/cmp.routerBlobsCreatePathHandler~impl] pkg/router/impl_apiv2.go:127:impl

  3. [~server.apiv2.blobs/it.TestBlobsCreate~impl] pkg/sys/it/impl_blob_test.go:38:impl