Skip to content

Latest commit

 

History

History
95 lines (59 loc) · 4.83 KB

2.x.x to 3.x.x.md

File metadata and controls

95 lines (59 loc) · 4.83 KB

Migration guide for versions 2.x.x -> 3.x.x

This release contains a number of changes. The most notable are:

  • Drop support for Node versions below 12.
  • Bump jsonwebtoken to version 9.0.0.

Runtime requirements

From this version, we will only support Node versions 12 and above. This is due to the fact that jsonwebtoken version 9.0.0 dropped support for Node versions below 12. If you are using an older version of Node, you will need to upgrade to a newer version.

Dependencies

jsonwebtoken

We have bumped the version of jsonwebtoken to 9.0.0 to fix a security vulnerability. If you are using jsonwebtoken directly, you will need to upgrade to version 9.0.0 to avoid conflicts.

Removed deprecated methods and classes

Box Client

The deprecated BoxClient.batch() and BoxClient.batchExec() methods have been removed, please make calls in parallel instead.

Attribute staleBufferMS in UserConfigurationOptions class has been removed, you can use expiredBufferMS attribute to set the time before we consider the token expired.

Collaboration Whitelist

The deprecated CollaborationWhitelist class has been removed, please use CollaborationAllowlist class instead.

Collaboration Allowlist

Method CollaborationAllowlist.getWhitelistedDomain() has been removed, now to get the allow listed domain, use CollaborationAllowlist.getAllowlistedDomain() instead.

Method CollaborationAllowlist.getAllWhitelistedDomains() has been removed, now to get all allow listed domains, use CollaborationAllowlist.getAllAllowlistedDomains() instead.

Files

Method Files.getThumbnail( fileID: string, options?: Record<string, any>, callback?: Function ) has been removed, use Files.getRepresentationContent( fileID, representationType, options, callback) instead.

With this method, you can generate a representation of a file. A representation is an alternative asset for a file stored in Box. These assets can be PDFs, thumbnails, or text extractions.

Representations are automatically generated for the supported file types, either when uploading to Box or when requesting the asset.

Useful links

Example

To get the thumbnail for a file has the extension in this list of supported file types, you can use the following code:

const thumbnail = await client.files.getRepresentationContent('123', client.files.representations.THUMBNAIL);
thumbnail.pipe(fs.createWriteStream('thumbnail.jpg'));

For others file types, you can get the list of representations available for a file using the Files.getRepresentationInfo() method, then use the Files.getRepresentationContent() method to get the content of the representation.

const representations = await client.files.getRepresentationInfo(fileId);
const representation = representations.entries.find((entry) => entry.representation === 'png');
if (!representation) {
    console.log('No png representation');
    return;
}
const png = await client.files.getRepresentationContent(fileId, `[${representation.representation}?dimensions=${representation.properties.dimensions}]`);
png.pipe(fs.createWriteStream('file.png'));