Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blackbeam/cfr
jQuery chunked file read plugin
https://github.com/blackbeam/cfr
Last synced: 20 days ago
JSON representation
jQuery chunked file read plugin
- Host: GitHub
- URL: https://github.com/blackbeam/cfr
- Owner: blackbeam
- Created: 2013-02-03T14:52:18.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-02-19T10:39:11.000Z (almost 12 years ago)
- Last Synced: 2023-04-10T02:17:28.912Z (over 1 year ago)
- Language: JavaScript
- Size: 129 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
cfr
===jQuery plugin for chunked file reading.
### Basic setup
```javascript
$('input[type=file]').cfr();
```### Options
* `chunkSize` - chunk size in bytes.
* `readFunc` - function to call on [FileReader](https://developer.mozilla.org/en-US/docs/DOM/FileReader) (`readAsDataURL` by default ).
* `filter` - function to call on chunk before pass it to `onChunk` callback (`function (c) { return c.substr(c.indexOf(',') + 1); }` by default).If you override a `readFunc` you also need override a default `filter` or pass it a `null`.
### Callbacks
* `onStart(file)` - will be called before reading first chunk.
* `file` - [File](https://developer.mozilla.org/en-US/docs/DOM/File) object.
* `onChunk(chunk, size, chunkNum, chunks, file, cb)` - will be called on each chunk.
* `chunk` - output of `filter` function if present. Instead a result of FileReaders `onloadend` event.
* `size` - count of bytes read from `file`.
* `chunkNum` - number of chunk.
* `chunks` - count of chunks in file.
* `file` - [File](https://developer.mozilla.org/en-US/docs/DOM/File) object.
* `cb` - function you must call to continue reading. You also can call `cb(true)` to cancel reading and trigger `onCancel` callback.
* `onCancel(file)` - will be called after `cb(true)` or `.cfr('cancel')`.
* `file` - [File](https://developer.mozilla.org/en-US/docs/DOM/File) object.
* `onFinish(file)` - will be called after last chunk read.
* `file` - [File](https://developer.mozilla.org/en-US/docs/DOM/File) object.
* `onEnd(file)` - will be called after `onCancel` or `onFinish`
* `file` - [File](https://developer.mozilla.org/en-US/docs/DOM/File) object.
* `onNotSupported()` - will be called on plugin initialization if FileReader API is not supported.### Methods
* `.cfr('cancel')` - cancel reading process
* `.cfr('remove')` - removing *cfr* from element (does not abort read process)### Example
See test.html for complete example.