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.

MimeType string

MIME type of the file.

SizeBytes int64

File size in bytes.

minimum-9007199254740991
maximum9007199254740991
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"

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",
  "mimeType": "mimeType",
  "sizeBytes": -9007199254740991,
  "status": "PENDING"
}
Returns Examples
{
  "id": "id",
  "completedAt": "completedAt",
  "createdAt": "createdAt",
  "expiresAt": "expiresAt",
  "filename": "filename",
  "mimeType": "mimeType",
  "sizeBytes": -9007199254740991,
  "status": "PENDING"
}