Update a file’s content. For file sizes over 50MB we recommend using the Chunk Upload APIs.
The attributes part of the body must come before the
file part. Requests that do not follow this format when
uploading the file will receive a HTTP 400 error with a
metadata_after_file_contents error code.
This operation is performed by calling function uploadFileVersion.
See the endpoint docs at API Reference.
await client.uploads.uploadFileVersion(file.id, {
attributes: {
name: file.name!,
} satisfies UploadFileVersionRequestBodyAttributesField,
file: generateByteStream(20),
} satisfies UploadFileVersionRequestBody);
string
https://*.app.box.com/files/123 the file_id is 123. Example: “12345”UploadFileVersionRequestBody
UploadFileVersionOptionalsInputThis function returns a value of type Files.
Returns the new file object in a list.
Performs a check to verify that a file will be accepted by Box before you upload the entire file.
This operation is performed by calling function preflightFileUploadCheck.
See the endpoint docs at API Reference.
await client.uploads.preflightFileUploadCheck({
name: newFileName,
size: 1024 * 1024,
parent: { id: '0' } satisfies PreflightFileUploadCheckRequestBodyParentField,
} satisfies PreflightFileUploadCheckRequestBody);
PreflightFileUploadCheckRequestBody
PreflightFileUploadCheckHeadersInput
undefined | CancellationToken
This function returns a value of type UploadUrl.
If the check passed, the response will include a session URL that can be used to upload the file to.
Uploads a small file to Box. For file sizes over 50MB we recommend using the Chunk Upload APIs.
The attributes part of the body must come before the
file part. Requests that do not follow this format when
uploading the file will receive a HTTP 400 error with a
metadata_after_file_contents error code.
This operation is performed by calling function uploadFile.
See the endpoint docs at API Reference.
const fs = require('fs');
const attrs = { name: 'filename.txt', parent: { id: '0' } };
const body = {
attributes: attrs,
file: fs.createReadStream('filename.txt'),
};
const files = await client.uploads.uploadFile(body);
const file = files.entries[0];
console.log(`File uploaded with id ${file.id}, name ${file.name}`);
UploadFileRequestBody
UploadFileOptionalsInputThis function returns a value of type Files.
Returns the new file object in a list.