Skip to content

Get a file download URL

client.File.URL(ctx, id) (*FileURLResponse, error)
GET/v1/files/{id}/url

Returns a temporary download URL for the file. Only available for files in COMPLETED status. Works for any retrievable file id, including files uploaded through the app.

A Google Drive, OneDrive or SharePoint file returns a presigned S3 URL for a temporary copy of that file version. The storage is asked whether the caller can still open the file, and whether it allows them to download it, before the copy is served. A folder returns 409 with code file_is_folder. A file whose owner has turned off downloading, and a Google type that cannot be exported, return 409 with code file_not_downloadable. A caller who has not connected that storage returns 409 with code drive_not_connected. A file over 50 MB returns 400 with code file_too_large. A storage failure returns 502 with code drive_download_provider_unavailable. Anyone who is not a user, including a workspace API key, receives not-found.

Synced email attachments are fetched from the mail provider on first download. If the provider fails, the call returns 502 with code mail_attachment_provider_unavailable. Retry once at most, then skip the attachment: some attachments fail on every request. After repeated provider failures for one attachment, Lightfield stops asking the provider for it for up to an hour and returns the same error immediately.

Required scope: files:read

Rate limit category: Read

ParametersExpand Collapse
id string

Unique identifier of the file to download.

ReturnsExpand Collapse
type FileURLResponse struct{…}
ExpiresAt string

When the download URL expires.

URL string

Temporary download URL for the file.

Get a file download URL

package main

import (
  "context"
  "fmt"

  "github.com/Lightfld/lightfield-go"
  "github.com/Lightfld/lightfield-go/option"
)

func main() {
  client := githubcomlightfldlightfieldgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  fileURLResponse, err := client.File.URL(context.TODO(), "id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", fileURLResponse.ExpiresAt)
}
{
  "expiresAt": "expiresAt",
  "url": "url"
}
Returns Examples
{
  "expiresAt": "expiresAt",
  "url": "url"
}