Step 1: Request an upload permission from Scrivito
The response grants the client permission to upload a file to Scrivito’s blob storage.
Multistep process for uploading a binary file (JPG, PDF, etc.) for referencing it from an object attribute.
Step 1: Request an upload permission from Scrivito
The response grants the client permission to upload a file to Scrivito’s blob storage.
Params
tenant_id
– The ID of the tenant.Response
The blob upload permission.
Example
Step 2: Upload the file to the URL provided in the response
Provide the fields as parameters. The storage server itself then verifies the signature of these parameters prior to accepting the upload. Specify all the fields, but don’t hard-code this list anywhere in your code. Instead, process the fields in the fields
value dynamically. Make sure to add a file
field as the last field.
If successful, take the blob
value of the upload permission and use it as an upload parameter in the next step.
Example
Step 3: Activate the uploaded blob
Until then, the blob upload is only temporary and is treated as garbage to be collected eventually. Activation instructs Scrivito to keep the blob and make it ready for referencing it from objects.
Params
tenant_id
– The ID of the tenant.Params as part of the payload
filename
– The name of the blob. This filename will become part of the blob’s download URL and hence be the suggested filename when saving the blob to a local disk.content_type
– The MIME-Type of the blob content.obj_id
– The ID of the CMS object the blob should be activated for. Only this object is allowed to reference the blob afterwards. To create a new object, specify a random ID.upload
– The value of the blob
field from step 2.Response
The blob handle. It includes the id
of the blob.
Since this action is performed in the background, please refer to the tasks API for polling the task status until the result is returned.
Example
Step 4: Reference the blob from a CMS object
Refer to Create or update an object for how to set object attributes. The value of a binary attribute needs to be specified as the pair ["binary", {"id": blob_id}]
.
Example