Skip to content

Cancel a file upload

file.cancel(strid, FileCancelParams**kwargs) -> FileCancelResponse
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: str

Unique identifier of the file to cancel.

body: Optional[Body]
ReturnsExpand Collapse
class FileCancelResponse:
id: str

Unique identifier for the file.

completed_at: Optional[str]

When the file upload was completed.

created_at: str

When the file upload session was created.

expires_at: Optional[str]

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

filename: str

Original filename.

mime_type: str

MIME type of the file.

size_bytes: int

File size in bytes.

minimum-9007199254740991
maximum9007199254740991
status: Literal["PENDING", "COMPLETED", "CANCELLED", "EXPIRED"]

Current upload status of the file.

One of the following:
"PENDING"
"COMPLETED"
"CANCELLED"
"EXPIRED"

Cancel a file upload

from lightfield import Lightfield

client = Lightfield(
    api_key="My API Key",
)
file_cancel_response = client.file.cancel(
    id="id",
)
print(file_cancel_response.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"
}