Skip to content

Cancel a file upload

client.File.Cancel(ctx, id, body) (*FileCancelResponse, error)
POST/v1/files/{id}/cancel

Cancels a pending upload by transitioning the file to CANCELLED. Only files in PENDING status can be cancelled. Required scope: files:create

Rate limit category: Write

ParametersExpand Collapse
id string

Unique identifier of the file to cancel.

body FileCancelParams
Body param.Field[FileCancelParamsBody]Optional
ReturnsExpand Collapse
type FileCancelResponse 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 FileCancelResponseKind

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

One of the following:
const FileCancelResponseKindFile FileCancelResponseKind = "file"
const FileCancelResponseKindFolder FileCancelResponseKind = "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 FileCancelResponseSource

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 FileCancelResponseSourceGoogleDrive FileCancelResponseSource = "googleDrive"
const FileCancelResponseSourceMicrosoftDrive FileCancelResponseSource = "microsoftDrive"
Status FileCancelResponseStatus

Current upload status of the file.

One of the following:
const FileCancelResponseStatusPending FileCancelResponseStatus = "PENDING"
const FileCancelResponseStatusCompleted FileCancelResponseStatus = "COMPLETED"
const FileCancelResponseStatusCancelled FileCancelResponseStatus = "CANCELLED"
const FileCancelResponseStatusExpired FileCancelResponseStatus = "EXPIRED"
WebURL string

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

Cancel 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"),
  )
  fileCancelResponse, err := client.File.Cancel(
    context.TODO(),
    "id",
    githubcomlightfldlightfieldgo.FileCancelParams{

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