Optional
options: ClientOptionsReturns filestack utils
Client
Download file by handle
client.download('fileHandle').then((response) => {
const img = new Image();
img.src = URL.createObjectURL(res.data)
document.body.appendChild(img);
}).catch((err) => {
console.error(err);
})
Error
Valid file handle
Optional
security: SecurityClear all current cloud sessions in the picker. Optionally pass a cloud source name to only log out of that cloud source. This essentially clears the OAuth authorization codes from the Filestack session.
Optional
name: stringOptional cloud source name.
Retrieve detailed data of stored files.
client
.metadata('DCL5K46FS3OIxb5iuKby')
.then((res) => {
console.log(res);
})
.catch((err) => {
console.log(err);
}));
Valid Filestack handle.
Optional
options: MetadataOptionsMetadata fields to enable on response.
Optional
security: SecurityOptional security override.
Initiates a multi-part upload flow. Use this for Filestack CIN and FII uploads.
In Node runtimes the file argument is treated as a file path. Uploading from a Node buffer is not yet implemented.
const token = {};
const onRetry = (obj) => {
console.log(`Retrying ${obj.location} for ${obj.filename}. Attempt ${obj.attempt} of 10.`);
};
client.multiupload([file], { onRetry }, token)
.then(res => console.log(res));
client.multiupload([{file, name}], { onRetry }, token)
.then(res => console.log(res));
token.pause(); // Pause flow
token.resume(); // Resume flow
token.cancel(); // Cancel flow (rejects)
Must be a valid [File | Blob | Buffer | string (base64)]
Optional
options: UploadOptionsOptional
storeOptions: StoreUploadOptionsStorage options.
Optional
token: anyA control token that can be used to call cancel(), pause(), and resume().
Optional
security: SecurityOptional security policy and signature override.
Construct a new picker instance.
Optional
options: PickerOptionsMake basic prefetch request to check permissions
Used for viewing files via Filestack handles or storage aliases, requires Document Viewer addon to your Filestack application. Opens document viewer in new window if id option is not provided.
// <div id="preview"></div>
client.preview('DCL5K46FS3OIxb5iuKby', { id: 'preview' });
Valid Filestack handle.
Optional
options: PreviewOptionsPreview options
Remove a file from storage and the Filestack system.
Requires a valid security policy and signature. The policy and signature will be pulled from the client session, or it can be overridden with the security parameter.
client
.remove('DCL5K46FS3OIxb5iuKby')
.then((res) => {
console.log(res);
})
.catch((err) => {
console.log(err);
}));
Valid Filestack handle.
Optional
security: SecurityOptional security override.
Remove a file only from the Filestack system. The file remains in storage.
Requires a valid security policy and signature. The policy and signature will be pulled from the client session, or it can be overridden with the security parameter.
client
.removeMetadata('DCL5K46FS3OIxb5iuKby')
.then((res) => {
console.log(res);
})
.catch((err) => {
console.log(err);
}));
Valid Filestack handle.
Optional
security: SecurityOptional security override.
Access files via their Filestack handles.
If head option is provided - request headers are returned in promise If metadata option is provided - metadata object is returned in promise Otherwise file blob is returned Metadata and head options cannot be mixed
client.retrieve('fileHandle', {
metadata: true,
}).then((response) => {
console.log(response);
}).catch((err) => {
console.error(err);
})
use metadata or download methods instead
Error
Valid file handle
Optional
options: RetrieveOptionsRetrieveOptions
Optional
security: SecurityOptional security override.
Store a file from its URL.
client
.storeURL('https://d1wtqaffaaj63z.cloudfront.net/images/NY_199_E_of_Hammertown_2014.jpg')
.then(res => console.log(res));
Valid URL to a file.
Optional
storeParams: StoreParamsOptional
token: anyOptional control token to call .cancel()
Optional
security: SecurityOptional security override.
Optional
uploadTags: UploadTagsOptional tags visible in webhooks.
Optional
headers: { Optional headers to send
Optional
workflowIds: string[]Optional workflowIds to send
Interface to the Filestack Processing API. Convert a URL, handle, or storage alias to another URL which links to the transformed file. You can optionally store the returned URL with client.storeURL.
Transform params can be provided in camelCase or snakeCase style ie: partial_pixelate or partialPixelate
const transformedUrl = client.transform(url, {
crop: {
dim: [x, y, width, height],
},
vignette: {
blurmode: 'gaussian',
amount: 50,
},
flip: true,
partial_pixelate: {
objects: [[10, 20, 200, 250], [275, 91, 500, 557]],
},
};
// optionally store the new URL
client.storeURL(transformedUrl).then(res => console.log(res));
A new URL that points to the transformed resource.
Single or multiple valid URLs (http(s)://), file handles, or storage aliases (src://) to an image.
Transformations are applied in the order specified by this object.
Use new more safe format for generating transforms url (default=false) Note: If there will be any issues with url please test it with enabled b64 support
Initiates a multi-part upload flow. Use this for Filestack CIN and FII uploads.
In Node runtimes the file argument is treated as a file path. Uploading from a Node buffer is not yet implemented.
const token = {};
const onRetry = (obj) => {
console.log(`Retrying ${obj.location} for ${obj.filename}. Attempt ${obj.attempt} of 10.`);
};
client.upload(file, { onRetry }, { filename: 'foobar.jpg' }, token)
.then(res => console.log(res));
client.upload({file, name}, { onRetry }, { filename: 'foobar.jpg' }, token)
.then(res => console.log(res));
token.pause(); // Pause flow
token.resume(); // Resume flow
token.cancel(); // Cancel flow (rejects)
Must be a valid [File | Blob | Buffer | string]
Optional
options: UploadOptionsOptional
storeOptions: StoreUploadOptionsStorage options.
Optional
token: anyA control token that can be used to call cancel(), pause(), and resume().
Optional
security: SecurityOptional security policy and signature override.
The Filestack client, the entry point for all public methods. Encapsulates session information.
Example