jQuery plugin for chunked file reading.
$('input[type=file]').cfr();
chunkSize
- chunk size in bytes.readFunc
- function to call on FileReader (readAsDataURL
by default ).filter
- function to call on chunk before pass it toonChunk
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
.
onStart(file)
- will be called before reading first chunk.file
- File object.
onChunk(chunk, size, chunkNum, chunks, file, cb)
- will be called on each chunk.chunk
- output offilter
function if present. Instead a result of FileReadersonloadend
event.size
- count of bytes read fromfile
.chunkNum
- number of chunk.chunks
- count of chunks in file.file
- File object.cb
- function you must call to continue reading. You also can callcb(true)
to cancel reading and triggeronCancel
callback.
onCancel(file)
- will be called aftercb(true)
or.cfr('cancel')
.file
- File object.
onFinish(file)
- will be called after last chunk read.file
- File object.
onEnd(file)
- will be called afteronCancel
oronFinish
file
- File object.
onNotSupported()
- will be called on plugin initialization if FileReader API is not supported.
.cfr('cancel')
- cancel reading process.cfr('remove')
- removing cfr from element (does not abort read process)
See test.html for complete example.