For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Logo
ContactLearn More
GuidesReferenceSamplesLicenseChangelog
GuidesReferenceSamplesLicenseChangelog
  • Concepts
    • Overview
    • Principles
  • Getting started
    • Set up
    • Authenticate
    • Quickstart
  • Best practices
    • Choose a protocol
    • Connect offline
    • Retry connections
  • Developer tools
    • Sandboxes
  • Entities
    • Overview
    • Watch
    • Publish
  • Tasks
    • Overview
    • Operate
    • Listen
    • Update
  • Objects
    • Overview
    • Upload
    • Download
    • Manage
ContactLearn More
On this page
  • Before you begin
  • Download an object
  • What’s next?
Objects

Download an object

Getting data from Lattice using the SDK
Previous

Manage objects

Getting metadata, and managing the lifecycle of objects using the Lattice SDK
Next

In Lattice, an object is a data model that represents a single file or a piece of data. This page explains how to retrieve objects from Lattice.

Before you begin

  • To configure your app to upload objects, set up your Lattice environment.
  • See an overview of the Object schema and the Object Store API in Lattice.

Download an object

In Lattice, an object is a data model that represents a single file or a piece of data. To download a specific binary object from Lattice using its unique object path, do the following:

1

Get the object path

When using the DownloadObject API, you must specify the object path of the object you want to download at runtime.

In the previous procedure, you uploaded the following objects:

  • Image: A .jpg image at the following path: /api/v1/objects/cessna.jpg. This image is a thumbnail of its associated track entity.
  • CSV: A .csv file at the following path: /api/v1/objects/manifest.csv. This serves as metadata, in this case, a vessel manifest for the associated entity. Choose one, and note the object path.
2

Download the object

Run the following code in the directory where you’d like to download the object. To download, use the GetObject operation. Replace the following:

  • object_path: the unique path of the object in Lattice.
1package main
2
3import (
4 "context"
5 "fmt"
6 "io"
7 "net/http"
8 "os"
9
10 Lattice "github.com/anduril/lattice-sdk-go/v4"
11 "github.com/anduril/lattice-sdk-go/v4/client"
12 "github.com/anduril/lattice-sdk-go/v4/option"
13)
14
15func main() {
16 // Get environment variables
17 latticeEndpoint := os.Getenv("LATTICE_ENDPOINT")
18 clientSecret := os.Getenv("LATTICE_CLIENT_SECRET")
19 clientId := os.Getenv("LATTICE_CLIENT_ID")
20
21 // Remove sandboxesToken from the following statements if you are not developing on Sandboxes
22 sandboxesToken := os.Getenv("SANDBOXES_TOKEN")
23
24 // Check required environment variables
25 if latticeEndpoint == "" || clientId == "" || clientSecret == "" || sandboxesToken == "" {
26 fmt.Println("Missing required environment variables")
27 os.Exit(1)
28 }
29
30 // Initialize headers for sandbox authorization
31 headers := http.Header{}
32 headers.Add("Anduril-Sandbox-Authorization", fmt.Sprintf("Bearer %s", sandboxesToken))
33
34 // Create the client
35 c := client.NewClient(
36 option.WithClientCredentials(clientId, clientSecret),
37 option.WithBaseURL(fmt.Sprintf("https://%s", latticeEndpoint)),
38 option.WithHTTPHeader(headers),
39 )
40 // Set object path
41 objectPath := "<OBJECT_PATH>"
42
43 // Create context for the request
44 ctx := context.Background()
45
46 // Get the object
47 response, err := c.Objects.GetObject(ctx, &Lattice.GetObjectRequest{ObjectPath: objectPath})
48 if err != nil {
49 fmt.Printf("Error getting object: %v\n", err)
50 os.Exit(1)
51 }
52 // Create output file
53 file, err := os.Create(objectPath)
54 if err != nil {
55 fmt.Printf("Error creating file: %v\n", err)
56 os.Exit(1)
57 }
58 defer file.Close()
59
60 // Copy data from response to file
61 _, err = io.Copy(file, response)
62 if err != nil {
63 fmt.Printf("Error writing to file: %v\n", err)
64 os.Exit(1)
65 }
66
67 fmt.Printf("Object downloaded successfully. Object path: %s\n", objectPath)
68}
3

Verify the response

If successful, you’ll see the following output:

$INFO - HTTP Request: GET https://lattice-50802.env.sandboxes.developer.anduril.com/api/v1/objects/your_object_name "HTTP/1.1 200 OK"

What’s next?

  • Learn more about the Objects API.