Skip to content

Complete a file upload

client.File.Complete(ctx, id, body) (*FileCompleteResponse, error)
POST/v1/files/{id}/complete

Finalizes an upload after the file bytes have been uploaded.

If an optional md5 hex digest is provided, the server validates the checksum before marking the file as completed.

Required scope: files:create

Rate limit category: Write

ParametersExpand Collapse
id string

Unique identifier of the file to complete.

body FileCompleteParams
Md5 param.Field[string]Optional

Optional MD5 hex digest of the uploaded file for checksum verification.

ReturnsExpand Collapse
type FileCompleteResponse 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 FileCompleteResponseKind

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

One of the following:
const FileCompleteResponseKindFile FileCompleteResponseKind = "file"
const FileCompleteResponseKindFolder FileCompleteResponseKind = "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 FileCompleteResponseSource

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 FileCompleteResponseSourceGoogleDrive FileCompleteResponseSource = "googleDrive"
const FileCompleteResponseSourceMicrosoftDrive FileCompleteResponseSource = "microsoftDrive"
Status FileCompleteResponseStatus

Current upload status of the file.

One of the following:
const FileCompleteResponseStatusPending FileCompleteResponseStatus = "PENDING"
const FileCompleteResponseStatusCompleted FileCompleteResponseStatus = "COMPLETED"
const FileCompleteResponseStatusCancelled FileCompleteResponseStatus = "CANCELLED"
const FileCompleteResponseStatusExpired FileCompleteResponseStatus = "EXPIRED"
WebURL string

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

Complete a file upload

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"),
  )
  fileCompleteResponse, err := client.File.Complete(
    context.TODO(),
    "id",
    githubcomlightfldlightfieldgo.FileCompleteParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", fileCompleteResponse.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"
}