Use Case - Attachments

You can attach files, blobs to any object in Jungle.

Some examples include shipping labels, login tags, and data exports.

Client workflow (Apps)

A recommended workflow for capturing a file from the user is to do the following:

  1. Show a file upload prompt, file selection, or take a photo.

  2. Once the file is selected, signature drawn, or photo taken, make the following query:

    query UploadToken($path: ID!, $filename: String) {
      attachmentUploadToken(input: { object: { path: $path }, filename: $filename }) {
        __typename
        ... on UploadToken {
          url
          expiresAt
          bytesMax
        }
      }
    }
  3. Using the url, in the client, complete a file upload to url.

  4. The attachment will be located at ${path}/attachments/${filename}.

🤖 If you need to do multiple file uploads, you'll need a signed URL per file.

View attachments

You may view attachments on an object:

query Attachments($path: ID!) {
  attachmentListV2(input: { object: { path: $path } }) {
    pageInfo {
      hasMore
      limit
    }
    results {
      attachment {
        path
        createdAt
        ... on Attachment {
          name
          tags
          contentType
          md5
          crc32c
          etag
          size
          modifiedAt
        }
      }
    }
  }
}

Download attachment

When a user wants to download a file, the client should request a URL for the attachment.

❗️Avoid this when listing attachments (.url has a high cost). Request the URL when the user actions a download.

query AttachmentDownloadUrl($path: ID!) {
  object(input: { $path }) {
    ... on Attachment {
      url
    }
  }
}

The provided download URL will be short-lived.

Fill 1

Can't find what you're looking for?

Contact Us