UNPKG

1.1 kBTypeScriptView Raw
1import { UploadContext } from './upload-context';
2export interface FileUploader<NodeAttributes> {
3 /**
4 * Inserts the file (but doesn't start the upload operation) and returns an
5 * object with this to be uploaded file's attributes.
6 */
7 insert: (file: File) => NodeAttributes;
8 /**
9 * Starts the upload operation and returns a promise. The promise will be
10 * resolved by a successful upload with uploaded file's attributes, or rejected
11 * because of an error.
12 *
13 * `upload` can update the object `context` to update information during
14 * the upload process. `context` will be passed to the render function. The
15 * render function can add a listener to `context` by using `context.addListener`
16 * to get the updated values. The default render function will try to find the
17 * keys `loaded` and `total` in `context`, which are two numbers that
18 * represent the progress of the upload.
19 */
20 upload: (context: UploadContext) => Promise<NodeAttributes>;
21 /**
22 * Aborts the upload operation.
23 */
24 abort: () => void;
25}