Skip to content

Import a file from Google Drive, OneDrive or SharePoint

client.File.NewFromStorage(ctx, body) (*FileCreateFromStorageResponse, error)
POST/v1/files/import

Copies a file from the caller’s connected Google Drive, OneDrive or SharePoint into a new file, without sending its bytes through the caller. Use it for files too large to download and re-upload, such as meeting recordings, up to 512 MB.

The file is checked before the call returns: a folder returns 409 with code file_is_folder, a Google Drive file whose owner has turned off downloading returns 409 with code file_not_downloadable (OneDrive and SharePoint report a blocked download only during the copy, which then ends as CANCELLED), a link that is not a Google Drive, OneDrive or SharePoint file returns 409 with code file_not_downloadable, and a caller who has not connected that storage returns 409 with code drive_not_connected. A file whose MIME type or size does not fit purpose returns 400. Google Docs, Sheets and Slides cannot be imported.

The copy runs in the background. The response is the new file with status PENDING. Poll GET /v1/files/{id} until it is COMPLETED, then use its id like any uploaded file, for example as mediaFileId in POST /v1/meetings/{id}/recordings. A copy that fails ends as CANCELLED or EXPIRED; import the file again to retry. Imports read from the caller’s own storage connection, so a workspace API key or an automation run gets 403.

Supports idempotency via the Idempotency-Key header: within 72 hours, a repeat with the same key returns the same file while it is PENDING or COMPLETED, and a repeat sent while the first call is still running returns 409.

Required scope: files:create

Rate limit category: Write

ParametersExpand Collapse
body FileNewFromStorageParams
Purpose param.Field[FileNewFromStorageParamsPurpose]

What the file is for. meeting_recording for the audio or video of a meeting recording (MP4, WebM, QuickTime, MP3, M4A, WAV or OGG). meeting_transcript for a plain text or markdown transcript.

const FileNewFromStorageParamsPurposeMeetingRecording FileNewFromStorageParamsPurpose = "meeting_recording"
const FileNewFromStorageParamsPurposeMeetingTranscript FileNewFromStorageParamsPurpose = "meeting_transcript"
URL param.Field[string]

Link to the file in Google Drive, OneDrive or SharePoint, as the storage shows it or shares it.

ReturnsExpand Collapse
type FileCreateFromStorageResponse 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 FileCreateFromStorageResponseKind

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

One of the following:
const FileCreateFromStorageResponseKindFile FileCreateFromStorageResponseKind = "file"
const FileCreateFromStorageResponseKindFolder FileCreateFromStorageResponseKind = "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 FileCreateFromStorageResponseSource

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 FileCreateFromStorageResponseSourceGoogleDrive FileCreateFromStorageResponseSource = "googleDrive"
const FileCreateFromStorageResponseSourceMicrosoftDrive FileCreateFromStorageResponseSource = "microsoftDrive"
Status FileCreateFromStorageResponseStatus

Current upload status of the file.

One of the following:
const FileCreateFromStorageResponseStatusPending FileCreateFromStorageResponseStatus = "PENDING"
const FileCreateFromStorageResponseStatusCompleted FileCreateFromStorageResponseStatus = "COMPLETED"
const FileCreateFromStorageResponseStatusCancelled FileCreateFromStorageResponseStatus = "CANCELLED"
const FileCreateFromStorageResponseStatusExpired FileCreateFromStorageResponseStatus = "EXPIRED"
WebURL string

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

Import a file from Google Drive, OneDrive or SharePoint

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"),
  )
  fileCreateFromStorageResponse, err := client.File.NewFromStorage(context.TODO(), githubcomlightfldlightfieldgo.FileNewFromStorageParams{
    Purpose: githubcomlightfldlightfieldgo.FileNewFromStorageParamsPurposeMeetingRecording,
    URL: "url",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", fileCreateFromStorageResponse.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"
}