Manage objects
In Lattice, an object is a data model that represents a single file or a piece of data. This page explains how to manage objects in Lattice, including retrieving metadata, setting expiration times, and deleting objects.
Before you begin
- To configure your app to manage objects, set up your Lattice environment.
 - See an overview of the Object schema and the Object Store API in Lattice.
 - If you haven’t already, learn how to upload and download objects.
 
Get object metadata
To retrieve metadata about an object without downloading its contents,
use the getObjectMetadata method, which performs a HEAD request to the server.
This operation returns metadata such as the object size in bytes, the SHA-256 checksum, and timestamps indicating when the object was last modified, and when it expires.
Specify the object path
When using the GetObjectMetadata API, you must specify the object path of the object for which you want to retrieve metadata.
For example, if you previously uploaded an image at /api/v1/objects/image.jpg,
you would use this path to request its metadata.
Get the object metadata
Run the following code to retrieve the object’s metadata.
Replace objectPath with the path of the object.
Inspect the metadata
If successful, the response will include headers with valuable information:
You can use this information to verify the object size before downloading, confirm the object hasn’t been modified using the checksum, and check when the object expires and is removed from your environment.
Set object time-to-live
In Lattice, an object is a data model that represents a single file or a piece of data. When uploading objects, you can control how long they will be stored in Lattice by setting a Time-To-Live (TTL) value. This is useful for temporary files or for implementing storage policies.
Prepare the file and TTL value
Before uploading, you need to:
- Have a file ready to upload
 - Determine the desired time-to-live in nanoseconds
 
For example, to keep an object for 24 hours, you would set the TTL to:
24 * 60 * 60 * 1,000,000,000 nanoseconds (86,400,000,000,000 ns)
Upload with TTL header
Use the Lattice SDK to upload the object, adding the Time-To-Live request header to specify the TTL:
Verify the expiry time
If successful, Lattice sets an expiry time based on the value you specify in the
Time-To-Live header. The example from the previous steps confirms the result by
fetching the object’s metadata and checking the Expires header:
If you don’t set a TTL, Lattice will use a default typically set to 90 days. This default TTL policy might vary, based on your environment’s configurations.
Delete an object
In Lattice, an object is a data model that represents a single file or a piece of data. When you no longer need an object, you can delete it from Lattice to free up storage space. Deleting an object is a permanent operation that cannot be undone.
Delete the object
When using the DeleteObject API, you must specify the object path of the object you want to delete.
Replace the object path with your information, then run the following code to delete the object:
If successful, this produces an error with the following output: the object no longer exists”
(Optional) Unlink entity
When you delete an object, you must clean up any references to the object path in your environment.
For example, if the object is linked to an entity, using the entity’s Media component, your app must submit an Override
to remove the object path from the list. Run the following example:
If successful, you’ll see an output similar to the following, confirming that the entity’s Media component
is empty
What’s next?
- Learn more about the Objects API.
 - Explore how to use objects with Entities to associate binary data with your Lattice entities.