Isomorphic TypeScript file upload library for browser and node.js environments.
Quickstart:
npm install upload
# ...or
yarn add upload
Example usage
upload function
;
Upload class
Abort request
; upload.on'state',; upload.upload;upload.abort;
Events
You can attach event listeners to an instance of Upload
with .on
:
upload.on'state', ;
state
Emitted when upload state is changed. Possible states: new
, started
, aborted
, failed
, successful
.
error
Emitted when an error occurs.
progress (progress: number)
Emitted when upload progress changes. Progress is a float between 0 and 1.
API
; public state: UploadState;public progress = 0;public uploadedBytes = 0;public totalBytes = 0; new Uploadoptions: UploadOptions;upload: Promise<UploadResponse>;abort: void; oneventType: 'progress', listener:void: void;oneventType: 'error', listener:void: void;oneventType: 'state', listener:void: void; offeventType: 'progress', listener:void: void;offeventType: 'error', listener:void: void;offeventType: 'state', listener:void: void;