Skip to content

Retrieve a file

client.File.Get(ctx, id) (*FileRetrieveResponse, error)
GET/v1/files/{id}

Retrieves a single file by its ID.

This works for any file id you already hold, including ones returned in a CRM record’s $files relationship — not only files created through POST /v1/files. See File uploads for which document classes are retrievable by id versus enumerable through GET /v1/files.

Google Drive, OneDrive and SharePoint items add source, kind, parentId, webUrl, and modifiedAt. Those fields are null for every other file. A workspace API key receives not-found for a storage item id.

Required scope: files:read

Rate limit category: Read

ParametersExpand Collapse
id string

Unique identifier of the file to retrieve.

ReturnsExpand Collapse
type FileRetrieveResponse struct{…}
ID string

Unique identifier for the file.

CompletedAt string

When the file upload was completed.

CreatedAt string

When the file upload session was created.

ExpiresAt string

When the upload session expires. Null once completed, cancelled, or expired.

Filename string

Original filename.

Kind FileRetrieveResponseKind

Whether the item is a file or a folder. Null when the response was built without that column.

One of the following:
const FileRetrieveResponseKindFile FileRetrieveResponseKind = "file"
const FileRetrieveResponseKindFolder FileRetrieveResponseKind = "folder"
MimeType string

MIME type of the file.

ModifiedAt string

When the storage last modified this item. Null for a non-storage file, and for a storage item whose modified time has not been stored.

ParentID string

The storage folder this item sits in, or null for a top-level item or a non-storage file.

SizeBytes int64

File size in bytes.

minimum-9007199254740991
maximum9007199254740991
Source FileRetrieveResponseSource

Where the file came from. googleDrive for a linked Google Drive item, microsoftDrive for a linked OneDrive or SharePoint item. Null for every other file.

One of the following:
const FileRetrieveResponseSourceGoogleDrive FileRetrieveResponseSource = "googleDrive"
const FileRetrieveResponseSourceMicrosoftDrive FileRetrieveResponseSource = "microsoftDrive"
Status FileRetrieveResponseStatus

Current upload status of the file.

One of the following:
const FileRetrieveResponseStatusPending FileRetrieveResponseStatus = "PENDING"
const FileRetrieveResponseStatusCompleted FileRetrieveResponseStatus = "COMPLETED"
const FileRetrieveResponseStatusCancelled FileRetrieveResponseStatus = "CANCELLED"
const FileRetrieveResponseStatusExpired FileRetrieveResponseStatus = "EXPIRED"
WebURL string

A link that opens this item in Google Drive, OneDrive or SharePoint. Null for a non-storage file.

Retrieve a file

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"),
  )
  fileRetrieveResponse, err := client.File.Get(context.TODO(), "id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", fileRetrieveResponse.ID)
}
{
  "id": "id",
  "completedAt": "completedAt",
  "createdAt": "createdAt",
  "expiresAt": "expiresAt",
  "filename": "filename",
  "kind": "file",
  "mimeType": "mimeType",
  "modifiedAt": "modifiedAt",
  "parentId": "parentId",
  "sizeBytes": -9007199254740991,
  "source": "googleDrive",
  "status": "PENDING",
  "webUrl": "webUrl"
}
Returns Examples
{
  "id": "id",
  "completedAt": "completedAt",
  "createdAt": "createdAt",
  "expiresAt": "expiresAt",
  "filename": "filename",
  "kind": "file",
  "mimeType": "mimeType",
  "modifiedAt": "modifiedAt",
  "parentId": "parentId",
  "sizeBytes": -9007199254740991,
  "source": "googleDrive",
  "status": "PENDING",
  "webUrl": "webUrl"
}