Calls each of the listeners registered for a given event.
Return an array listing the events for which the emitter has registered listeners.
Return the number of listeners listening to a given event.
Return the listeners registered for a given event.
Clear 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 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.
Metadata fields to enable on response.
Optional 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)]
Storage options.
A control token that can be used to call cancel(), pause(), and resume().
Optional security policy and signature override.
Add a listener for a given event.
Add a one-time listener for a given event.
Construct a new picker instance.
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.
Preview 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 override.
Remove all listeners, or those of the specified event.
Remove the listeners of a given event.
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 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);
})
Valid file handle
RetrieveOptions
Optional security override.
Set custom cname
Set security object
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.
Configure file storage.
Optional control token to call .cancel()
Optional security override.
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));
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
A new URL that points to the transformed resource.
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]
Storage options.
A control token that can be used to call cancel(), pause(), and resume().
Optional security policy and signature override.
The Filestack client, the entry point for all public methods. Encapsulates session information.
Example
// ES module import * as filestack from 'filestack-js'; const client = filestack.init('apikey');// UMD module in browser <script src="https://static.filestackapi.com/filestack-js/3.x.x/filestack.min.js"></script> const client = filestack.init('apikey');