Skip to main content

Reading Blobs

You can read blobs using HTTP GET requests with their blob ID or object ID. Set $AGGREGATOR to an aggregator endpoint from the Network Reference.

Reading a blob right after upload?

When you read through a CDN-fronted aggregator immediately after certification, the CDN might briefly cache a 404 from before the blob propagated. If your app knows the blob was just certified, retry with backoff. See Reading Blobs Right After Upload.

Reading by blob ID​

The following curl command reads a blob and writes it to an output file:

$ curl "$AGGREGATOR/v1/blobs/<BLOB_ID>" -o <FILE_NAME>

To print the contents of a blob directly in the terminal:

$ curl "$AGGREGATOR/v1/blobs/<BLOB_ID>"
tip

Modern browsers attempt to sniff the content type for these resources and generally do a good job of inferring content types for media. The aggregator intentionally prevents sniffing from inferring dangerous executable types such as JavaScript or style sheet types.

Reading by object ID​

You can also read blobs by using the object ID of a Sui blob object or a shared blob. The following curl command downloads the blob corresponding to a Sui object ID:

$ curl "$AGGREGATOR/v1/blobs/by-object-id/<OBJECT_ID>" -o <FILE_NAME>

Downloading blobs by object ID allows setting HTTP headers. The aggregator recognizes the following attribute keys and returns the values in the corresponding HTTP headers when present: content-disposition, content-encoding, content-language, content-location, content-type, and link.

Consistency checks​

The consistency checks performed by the aggregator are the same as those performed by the CLI. For special use cases, you can enable the strict consistency check by adding a query parameter strict_consistency_check=true (starting with v1.35). If the writer of the blob is known and trusted, you can disable the consistency check by adding a query parameter skip_consistency_check=true (starting with v1.36).