Scrivito is proudly made by JustRelate Group in Berlin, Germany, and Wrocław, Poland.
Scrivito is proudly made by JustRelate Group

Get URLs of optimized blobs

Returns the URLs of a transformed blob optimized for the provided transformation specification.

GET /tenants/:tenant_id/blobs/:blob_id/optimize

To retrieve the binary data from an attribute such as blob, the actual URL of the binary needs to be determined first. For this, extract the blob’s id, unescape and URL-encode it, then use it for querying the URL.

Transformed images are delivered with a best effort approach. It is not guaranteed that the delivered transformation exactly matches the requested dimensions. The images are probably larger and need to be scaled down by the client as long as the transformation request does not exceed the image size limit. The size of the transformed image is limited to an aspect-ratio-retaining size fitting into 8192 by 8192 pixels.

For restricted blobs, no private URL but an inaccessible public URL is returned if the user does not have access to the object referencing the blob.

Params

  • tenant_id – The ID of the tenant.
  • blob_id – The ID of the blob.

Params as part of the payload

  • transformation – The transformation specification to apply. A transformation specification is a map describing a transformation request for an image. It contains the keys width, height and fit all of which are optional. width and height are required to be positive integer numbers. fit may be either crop or resize (default). An empty transformation is a valid value causing the returned blob to match the dimensions of the original, if possible.
  • access_via – The object space ID (working copy or revision) to be used to check for restrictions if applicable. This is ignored if the user is a visitor. In this case, restrictions are always checked against the published content.

Example of the transformation parameter:

{
  "width": 320, 
  "height": 200
}

Example of the access_via parameter:

"workspace:k69deba000fa8432"

Response

The URLs of the blob.

Access to preview URLs (giving access to unpublished blobs) is restricted to editors. Visitors cannot retrieve preview URLs.

Example

curl \
  -X GET \
  -H 'Content-Type: application/json' \
  -u 'api_token:MYTOKEN' \
  -d '{
    "transformation": {
      "width": 320, 
      "height": 200
    }
  }' \
  https://api.scrivito.com/tenants/:tenant_id/blobs/:blob_id/optimize
{
  "private_access": {
    "get": {
      "url": "https://…",
      "maxage": 3600
    },
    "head": {
      "url": "https://…",
      "maxage": 3600
    }
  },
  "public_access": {
    "get": {
      "url": "https://…",
      "maxage": 604800
    },
    "head": {
      "url": "https://…",
      "maxage": 604800
    }
  }
}