filestack-js
Advanced tools
Comparing version 0.5.2 to 0.6.0
# filestack-js changelog | ||
## 0.6.0 (2017-05-10) | ||
**Picker changes** | ||
- Implement webcam source for taking pictures | ||
- Remove sidebar pagination, implement sidebar scrolling | ||
- Fix performance issue in summary screen related to thumbnails | ||
- Implement onClose callback | ||
- Add new field `originalPath` to file data returned from pick | ||
**Breaking changes** | ||
- The multi-part `upload` method was rewritten. Options to this method have slightly changed. | ||
- The signature of progress events has also changed, please see the readme. | ||
## 0.5.2 (2017-04-20) | ||
@@ -4,0 +17,0 @@ - Fix one more transformations regression (sorry folks) |
{ | ||
"name": "filestack-js", | ||
"version": "0.5.2", | ||
"version": "0.6.0", | ||
"description": "Official browser client for Filestack", | ||
@@ -14,7 +14,10 @@ "author": "Filestack", | ||
"file", | ||
"multi-part", | ||
"upload", | ||
"multi-part", | ||
"uploader", | ||
"processing", | ||
"store", | ||
"picker" | ||
"images", | ||
"transformations", | ||
"S3", | ||
"filepicker" | ||
], | ||
@@ -28,3 +31,3 @@ "scripts": { | ||
"start": "http-server -o", | ||
"release-start": "release-o-tron --start", | ||
"release-start": "release-o-tron --start && npm run build", | ||
"release-finish": "release-o-tron --finish", | ||
@@ -36,9 +39,4 @@ "publish": "node scripts/publish.js" | ||
"jsnext:main": "dist/filestack.es2015.js", | ||
"dependencies": { | ||
"api-client": "http://static.filestackapi.com/packages/api-client/api-client-0.3.5.tar.gz", | ||
"es6-promise": "^4.1.0", | ||
"logger": "http://static.filestackapi.com/packages/logger/logger-1.3.3.tar.gz", | ||
"picker": "http://static.filestackapi.com/packages/picker/picker-0.5.4.tar.gz" | ||
}, | ||
"devDependencies": { | ||
"api-client": "http://static.filestackapi.com/packages/api-client/api-client-0.4.2.tar.gz", | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
@@ -52,2 +50,3 @@ "babel-preset-es2015": "^6.22.0", | ||
"electron-mocha": "^3.1.1", | ||
"es6-promise": "^4.1.0", | ||
"eslint": "^3.5.0", | ||
@@ -58,3 +57,5 @@ "eslint-config-airbnb-base": "^8.0.0", | ||
"http-server": "^0.9.0", | ||
"logger": "http://static.filestackapi.com/packages/logger/logger-1.3.3.tar.gz", | ||
"minimist": "^1.2.0", | ||
"picker": "http://static.filestackapi.com/packages/picker/picker-0.6.4.tar.gz", | ||
"pre-commit": "^1.1.3", | ||
@@ -68,3 +69,4 @@ "release-o-tron": "http://static.filestackapi.com/packages/release-o-tron/release-o-tron-1.3.6.tar.gz", | ||
"rollup-plugin-replace": "^1.1.1", | ||
"rollup-plugin-uglify": "^1.0.1" | ||
"rollup-plugin-uglify": "^1.0.1", | ||
"uglify-js": "github:mishoo/UglifyJS2#harmony" | ||
}, | ||
@@ -71,0 +73,0 @@ "pre-commit": [ |
204
README.md
filestack-js | ||
====================== | ||
Official browser client to the Filestack API's. Available via NPM and CDN script. | ||
Official browser client to the Filestack API's. Available via NPM and Filestack CDN. | ||
Filestack documentation can be found here: https://filestack.com/docs/ | ||
This SDK is shipped as both a UMD module and a ES2015 module for modern Javascript bundlers. There is also a separate minified version available on the Filestack CDN. | ||
This library is shipped as both a UMD module and a ES2015 module for modern Javascript bundlers. There is also a separate minified UMD module available on the Filestack CDN. | ||
@@ -25,5 +25,6 @@ ## Installation | ||
Via script tag: | ||
(Note http://static.filestackapi.com/v3/filestack.js will always point to the latest version. This is __not__ recommended for production.) | ||
```HTML | ||
<script src="http://static.filestackapi.com/v3/filestack-0.5.1.js"></script> | ||
<script src="http://static.filestackapi.com/v3/filestack-0.6.0.js"></script> | ||
<script> | ||
@@ -38,24 +39,31 @@ const apikey = 'abc'; | ||
* [filestack](#module_filestack) | ||
* [~version](#module_filestack..version) ⇒ <code>string</code> | ||
* [~init(apikey, [security])](#module_filestack..init) ⇒ <code>object</code> | ||
* [.getSecurity()](#module_filestack..init.getSecurity) ⇒ <code>object</code> | ||
* [init(apikey, [security])](#module_filestack..init) ⇒ <code>object</code> | ||
* [.getSecurity()](#module_filestack..init.getSecurity) ⇒ <code>object</code> | ||
* [.setSecurity(security)](#module_filestack..init.setSecurity) ⇒ <code>object</code> | ||
* [.metadata(handle, [options])](#module_filestack..init.metadata) ⇒ <code>Promise</code> | ||
* [.pick([options])](#module_filestack..init.pick) ⇒ <code>Promise</code> | ||
* [.storeURL(url, [options])](#module_filestack..init.storeURL) ⇒ <code>Promise</code> | ||
* [.remove(handle)](#module_filestack..init.remove) ⇒ <code>Promise</code> | ||
* [.retrieve(handle, [options])](#module_filestack..init.retrieve) ⇒ <code>Promise</code> | ||
* [.remove(handle)](#module_filestack..init.remove) ⇒ <code>Promise</code> | ||
* [.metadata(handle, [options])](#module_filestack..init.metadata) ⇒ <code>Promise</code> | ||
* [.storeURL(url, [options])](#module_filestack..init.storeURL) ⇒ <code>Promise</code> | ||
* [.transform(url, options)](#module_filestack..init.transform) ⇒ <code>string</code> | ||
* [.upload(file, [uploadOptions], [storeOptions])](#module_filestack..init.upload) ⇒ <code>Promise</code> | ||
* [~TransformOptions](#module_filestack..TransformOptions) : <code>object</code> | ||
* [~progressCallback](#module_filestack..progressCallback) : <code>function</code> | ||
* [~retryCallback](#module_filestack..retryCallback) : <code>function</code> | ||
* [version](#module_filestack..version) ⇒ <code>string</code> | ||
<a name="module_filestack..init"></a> | ||
### init(apikey, [security]) ⇒ <code>object</code> | ||
Initializes the client. | ||
**Returns**: <code>object</code> - Object containing client methods. | ||
**Params** | ||
- apikey <code>string</code> - Filestack API key. Get a free key [here](https://dev.filestack.com/register/free). | ||
- [security] <code>object</code> - Read about [security policies](https://www.filestack.com/docs/security). | ||
- .policy <code>string</code> - Filestack security policy encoded in base64. | ||
- .signature <code>string</code> - HMAC-SHA256 sIgnature for the security policy. | ||
<a name="module_filestack..version"></a> | ||
### filestack~version ⇒ <code>string</code> | ||
### version ⇒ <code>string</code> | ||
Gets current version. | ||
**Kind**: inner property of <code>[filestack](#module_filestack)</code> | ||
**Example** | ||
@@ -66,17 +74,2 @@ ```js | ||
``` | ||
<a name="module_filestack..init"></a> | ||
### filestack~init(apikey, [security]) ⇒ <code>object</code> | ||
Initializes the client. | ||
**Kind**: inner method of <code>[filestack](#module_filestack)</code> | ||
**Returns**: <code>object</code> - Object containing the available methods documented below. | ||
**Params** | ||
- apikey <code>string</code> - Filestack API key. Get a free key [here](https://dev.filestack.com/register/free). | ||
- [security] <code>object</code> - Read about [security policies](https://www.filestack.com/docs/security). | ||
- .policy <code>string</code> - Filestack security policy encoded in base64. | ||
- .signature <code>string</code> - HMAC-SHA256 sIgnature for the security policy. | ||
<a name="exp_module_pick--pick"></a> | ||
<a name="module_filestack..init.getSecurity"></a> | ||
@@ -87,3 +80,2 @@ | ||
**Kind**: static method of <code>[init](#module_filestack..init)</code> | ||
**Returns**: <code>object</code> - Object containing current security parameters | ||
@@ -95,9 +87,7 @@ <a name="module_filestack..init.setSecurity"></a> | ||
**Note:** Does not currently work with `pick`. You will need to re-init the client if you want to propagate new security parameters to the picker. | ||
**Note:** Does not currently work with `pick`. You will need to init a new client if you want to propagate new security parameters to the picker. | ||
**Kind**: static method of <code>[init](#module_filestack..init)</code> | ||
**Returns**: <code>object</code> - Object containing current session parameters | ||
**Params** | ||
- security <code>object</code> - Read about [security policies](https://www.filestack.com/docs/security). | ||
- security <code>object</code> - Read about [security policies](https://www.filestack.com/docs/security). | ||
- .policy <code>string</code> - Filestack security policy encoded in base64. | ||
@@ -116,4 +106,3 @@ - .signature <code>string</code> - HMAC-SHA256 sIgnature for the security policy. | ||
**Kind**: static method of <code>[init](#module_filestack..init)</code> | ||
**Fulfil**: <code>object</code> - Object contains keys `filesUploaded` and `filesFailed` which are both arrays of file metadata. | ||
**Resolve**: <code>object</code> - Object contains keys `filesUploaded` and `filesFailed` which are both arrays of file metadata. | ||
**Params** | ||
@@ -129,2 +118,3 @@ | ||
- `dropbox` - __Default__ | ||
- `webcam` - Desktop only. Please use `local_file_system` for mobile. Not currently supported in Safari or IE. | ||
- `evernote` | ||
@@ -173,2 +163,3 @@ - `flickr` | ||
- .onFileUploadFailed <code>[onFileUploadFailed](#module_pick--pick..onFileUploadFailed)</code> - Called when uploading a file fails. | ||
- .onClose <code>function</code> - Called when the UI is exited. | ||
@@ -184,4 +175,3 @@ **Example** | ||
#### client.pick~onFileSelected : <code>function</code> | ||
**Kind**: inner typedef of <code>[pick](#exp_module_pick--pick)</code> | ||
#### onFileSelected : <code>function</code> | ||
@@ -212,4 +202,3 @@ **Params** | ||
#### client.pick~onFileUploadStarted : <code>function</code> | ||
**Kind**: inner typedef of <code>[pick](#exp_module_pick--pick)</code> | ||
#### onFileUploadStarted : <code>function</code> | ||
@@ -222,4 +211,3 @@ **Params** | ||
#### client.pick~onFileUploadFinished : <code>function</code> | ||
**Kind**: inner typedef of <code>[pick](#exp_module_pick--pick)</code> | ||
#### onFileUploadFinished : <code>function</code> | ||
@@ -232,4 +220,3 @@ **Params** | ||
#### client.pick~onFileUploadFailed : <code>function</code> | ||
**Kind**: inner typedef of <code>[pick](#exp_module_pick--pick)</code> | ||
#### onFileUploadFailed : <code>function</code> | ||
@@ -243,4 +230,3 @@ **Params** | ||
#### client.pick~onFileUploadProgress : <code>function</code> | ||
**Kind**: inner typedef of <code>[pick](#exp_module_pick--pick)</code> | ||
#### onFileUploadProgress : <code>function</code> | ||
@@ -251,7 +237,4 @@ **Params** | ||
- event <code>object</code> - Progress event. | ||
- .totalProgressPercent <code>number</code> - Percent of total upload. | ||
- .progressTotal <code>number</code> - Total number of bytes uploaded thus far across all parts. | ||
- .part <code>number</code> - Part #. | ||
- .loaded <code>number</code> - Amount of data in this part that has been uploaded. | ||
- .byteLength <code>number</code> - Total number of bytes in this part. | ||
- .totalPercent <code>number</code> - Percent of file uploaded. | ||
- .totalBytes <code>number</code> - Total number of bytes uploaded for this file. | ||
@@ -263,4 +246,3 @@ <a name="module_filestack..init.storeURL"></a> | ||
**Kind**: static method of <code>[init](#module_filestack..init)</code> | ||
**Fulfil**: <code>object</code> - Metadata of stored file. | ||
**Resolve**: <code>object</code> - Metadata of stored file. | ||
**Reject**: <code>error</code> - A Superagent error object. | ||
@@ -291,4 +273,3 @@ **Params** | ||
**Kind**: static method of <code>[init](#module_filestack..init)</code> | ||
**Fulfil**: <code>object</code> - Metadata of stored file or stored file, depending on metadata / head option. | ||
**Resolve**: <code>object</code> - Metadata of stored file or stored file, depending on metadata / head option. | ||
**Reject**: <code>error</code> - A Superagent error object. | ||
@@ -323,4 +304,3 @@ **Params** | ||
**Kind**: static method of <code>[init](#module_filestack..init)</code> | ||
**Fulfil**: <code>object</code> - Result of remove. | ||
**Resolve**: <code>object</code> - Result of remove. | ||
**Reject**: <code>error</code> - A Superagent error object. | ||
@@ -348,4 +328,3 @@ **Params** | ||
**Kind**: static method of <code>[init](#module_filestack..init)</code> | ||
**Fulfil**: <code>object</code> - Result of metadata. | ||
**Resolve**: <code>object</code> - Result of metadata. | ||
**Reject**: <code>error</code> - A Superagent error object. | ||
@@ -392,3 +371,2 @@ **Params** | ||
**Kind**: static method of <code>[init](#module_filestack..init)</code> | ||
**Returns**: <code>string</code> - A new URL that points to the transformed resource. | ||
@@ -398,3 +376,3 @@ **Params** | ||
- url <code>string</code> - Valid URL to an image. | ||
- options <code>[TransformOptions](#module_filestack..TransformOptions)</code> - Transformations are applied in the order specified by this object. | ||
- options [<code>transformOptions</code>](#module_filestack..transformOptions) - Transformations are applied in the order specified by this object. | ||
@@ -422,43 +400,7 @@ **Example** | ||
``` | ||
<a name="module_filestack..init.upload"></a> | ||
<a name="module_filestack..transformOptions"></a> | ||
### client.upload(file, [uploadOptions], [storeOptions]) ⇒ <code>Promise</code> | ||
Initiates a multi-part upload flow. | ||
**Kind**: static method of <code>[init](#module_filestack..init)</code> | ||
**Fulfil**: <code>object</code> - Metadata of uploaded file. | ||
**Reject**: <code>error</code> - An error object depending on where the flow halted. | ||
#### transformOptions : <code>object</code> | ||
**Params** | ||
- file <code>File</code> - must be a valid [File](https://developer.mozilla.org/en-US/docs/Web/API/File). | ||
- [uploadOptions] <code>object</code> | ||
- [.partSize] <code>number</code> <code> = 5 * 1024 * 1024</code> - Size of each uploaded part. | ||
- [.maxConcurrentUploads] <code>number</code> <code> = 5</code> - Max number of concurrent uploads. | ||
- [.retryOptions] <code>object</code> - params for retry settings | ||
- [.retries] <code>number</code> <code> = 10</code> - max number of retries | ||
- [.factor] <code>number</code> <code> = 2</code> - the exponential factor to use | ||
- [.minTimeout] <code>number</code> <code> = 1 * 1000</code> - ms before starting first retry | ||
- [.maxTimeout] <code>number</code> <code> = 60 * 1000</code> - max ms between two retries | ||
- [.onStart] <code>function</code> - Called when the flow begins (before Filestack handshake request is made). | ||
- [.onUploadStart] <code>function</code> - Called when an upload begins (after S3 request is made). | ||
- [.onProgress] <code>[progressCallback](#module_filestack..progressCallback)</code> - Called on progress event. | ||
- [.onRetry] <code>[retryCallback](#module_filestack..retryCallback)</code> - Called if upload fails and retry is occurring | ||
- [.onUploadComplete] <code>function</code> - Called when an upload is completing (before final completion request). | ||
- [storeOptions] <code>object</code> - Configure where the file is stored. | ||
- .location <code>string</code> - Valid options are: `s3`, `gcs`, `dropbox`, `azure`, `rackspace`. | ||
- .container <code>string</code> - Name of the storage container. | ||
- [.region] <code>string</code> - Valid S3 region for the selected container (S3 only). | ||
- .path <code>string</code> - Path where the file will be stored. A trailing slash will put the file in that folder path. | ||
- .access <code>string</code> - Valid options are `private` or `public`. | ||
**Example** | ||
```js | ||
client.upload(file).then(res => console.log(res)); | ||
``` | ||
<a name="module_filestack..TransformOptions"></a> | ||
### filestack~TransformOptions : <code>object</code> | ||
**Kind**: inner typedef of <code>[filestack](#module_filestack)</code> | ||
**Params** | ||
- crop <code>object</code> - [Crop options.](https://www.filestack.com/docs/image-transformations/crop) | ||
@@ -512,21 +454,61 @@ - .dim <code>object</code> - Crop dimensions. | ||
<a name="module_filestack..init.upload"></a> | ||
### client.upload(file, [uploadOptions], [storeOptions], [token]) ⇒ <code>Promise</code> | ||
Initiates a direct-to-S3 multi-part upload. Uses Filestack S3 by default. Read how to configure your own S3 buckets [here](https://www.filestack.com/docs/cloud-storage/s3). | ||
**Resolve**: <code>object</code> - Metadata of uploaded file. | ||
**Reject**: <code>error</code> - An Error object depending on where the flow halted. | ||
**Params** | ||
- file <code>Blob</code> - must be a valid [File](https://developer.mozilla.org/en-US/docs/Web/API/File) or Blob. | ||
- [uploadOptions] <code>object</code> | ||
- [.partSize] <code>number</code> <code> = 6 * 1024 * 1024</code> - Size of each uploaded part. | ||
- [.concurrency] <code>number</code> <code> = 5</code> - Max number of concurrent parts uploading. | ||
- [.retry] <code>number</code> <code> = 10</code> - Number of times to retry a failed part of the flow. | ||
- [.progressInterval] <code>number</code> <code> = 1000</code> - Frequency (in milliseconds) at which progress events are dispatched. | ||
- [.onProgress] [<code>progressCallback</code>](#module_filestack..progressCallback) - Called regularly to give progress updates. | ||
- [.onRetry] [<code>retryCallback</code>](#module_filestack..retryCallback) - Called when a retry is initiated. | ||
- [storeOptions] <code>object</code> - Configure where the file is stored. | ||
- [.filename] <code>string</code> - Define a custom filename for the Blob/File being uploaded. | ||
- [.location] <code>string</code> <code> = "s3"</code> - Valid options are: `s3`, `gcs`, `dropbox`, `azure`, `rackspace`. | ||
- [.region] <code>string</code> - Valid S3 region for the selected container (S3 only). | ||
- [.container] <code>string</code> - Name of the storage container. | ||
- [.path] <code>string</code> - Path where the file will be stored. A trailing slash will put the file in that folder path. | ||
- [.access] <code>string</code> - Valid options are `private` or `public`. | ||
- [token] <code>object</code> - A control token that can be used to call cancel(), pause(), and resume(). | ||
**Example** | ||
```js | ||
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)); | ||
token.pause(); // Pause flow | ||
token.resume(); // Resume flow | ||
token.cancel(); // Cancel flow (rejects) | ||
``` | ||
<a name="module_filestack..progressCallback"></a> | ||
### filestack~progressCallback : <code>function</code> | ||
**Kind**: inner typedef of <code>[filestack](#module_filestack)</code> | ||
#### progressCallback : <code>function</code> | ||
**Params** | ||
- event <code>object</code> - Progress event. | ||
- .totalProgressPercent <code>number</code> - Percent of total upload. | ||
- .progressTotal <code>number</code> - Total number of bytes uploaded thus far across all parts. | ||
- .part <code>number</code> - Part #. | ||
- .loaded <code>number</code> - Amount of data in this part that has been uploaded. | ||
- .byteLength <code>number</code> - Total number of bytes in this part. | ||
### filestack~retryCallback : <code>function</code> | ||
**Kind**: inner typedef of <code>[filestack](#module_filestack)</code> | ||
- .totalPercent <code>number</code> - Percent of total file upload progress. | ||
- .totalBytes <code>number</code> - Total number of bytes uploaded thus far across all parts. | ||
<a name="module_filestack..retryCallback"></a> | ||
#### retryCallback : <code>function</code> | ||
**Params** | ||
- attempt <code>number</code> - Which attempt the upload is currently on. | ||
- nextAttempt <code>number</code> - ms before the attempt will start | ||
- retry <code>object</code> - Retry information object. | ||
- .location <code>string</code> - Which part of the flow is being retried. | ||
- .parts <code>Array.<object></code> - Array of current parts at this point in the flow. | ||
- .filename <code>string</code> - Name of the file being retried. | ||
- .attempt <code>number</code> - Current attempt. | ||
@@ -533,0 +515,0 @@ |
@@ -23,10 +23,2 @@ /* eslint-disable no-console */ | ||
}, | ||
onwarn(warning) { | ||
// Suppress this error message | ||
// https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined | ||
if (warning.code === 'THIS_IS_UNDEFINED') { | ||
return; | ||
} | ||
console.error(warning.message); | ||
}, | ||
plugins: [ | ||
@@ -33,0 +25,0 @@ inject({ |
@@ -12,2 +12,4 @@ /* eslint-disable no-console */ | ||
import commonJs from 'rollup-plugin-commonjs'; | ||
import uglify from 'rollup-plugin-uglify'; | ||
import uglify2 from 'uglify-js'; | ||
@@ -32,10 +34,2 @@ const argv = minimist(process.argv); | ||
}, | ||
onwarn(warning) { | ||
// Suppress this error message | ||
// https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined | ||
if (warning.code === 'THIS_IS_UNDEFINED') { | ||
return; | ||
} | ||
console.error(warning.message); | ||
}, | ||
plugins: [ | ||
@@ -54,5 +48,17 @@ inject({ | ||
}), | ||
nodeResolve(), | ||
nodeResolve({ | ||
module: true, | ||
jsnext: true, | ||
main: true, | ||
}), | ||
commonJs(), | ||
babel(babelrc()), | ||
uglify({ | ||
compress: false, | ||
mangle: false, | ||
output: { | ||
// Leave topmost comment with version | ||
comments: (node, comment) => comment.line === 1, | ||
}, | ||
}, uglify2.minify), | ||
], | ||
@@ -59,0 +65,0 @@ targets: [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
HTTP dependency
Supply chain riskContains a dependency which resolves to a remote HTTP URL which could be used to inject untrusted code and reduce overall package reliability.
Found 3 instances in 1 package
2878233
0
0
28
3431
497
1
- Removedapi-client@http://static.filestackapi.com/packages/api-client/api-client-0.3.5.tar.gz
- Removedes6-promise@^4.1.0
- Removedlogger@http://static.filestackapi.com/packages/logger/logger-1.3.3.tar.gz
- Removedpicker@http://static.filestackapi.com/packages/picker/picker-0.5.4.tar.gz
- Removedes6-promise@4.2.8(transitive)