1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | import { FbsBlob } from './implementation/blob';
|
21 | import { FirebaseStorageError } from './implementation/error';
|
22 | import { InternalTaskState, TaskEvent } from './implementation/taskenums';
|
23 | import { Metadata } from './metadata';
|
24 | import { CompleteFn, ErrorFn, StorageObserver, Subscribe, Unsubscribe } from './implementation/observer';
|
25 | import { UploadTaskSnapshot } from './tasksnapshot';
|
26 | import { Reference } from './reference';
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | export declare class UploadTask {
|
33 | private _ref;
|
34 | |
35 |
|
36 |
|
37 | _blob: FbsBlob;
|
38 | |
39 |
|
40 |
|
41 | _metadata: Metadata | null;
|
42 | private _mappings;
|
43 | |
44 |
|
45 |
|
46 | _transferred: number;
|
47 | private _needToFetchStatus;
|
48 | private _needToFetchMetadata;
|
49 | private _observers;
|
50 | private _resumable;
|
51 | |
52 |
|
53 |
|
54 | _state: InternalTaskState;
|
55 | private _error?;
|
56 | private _uploadUrl?;
|
57 | private _request?;
|
58 | private _chunkMultiplier;
|
59 | private _errorHandler;
|
60 | private _metadataErrorHandler;
|
61 | private _resolve?;
|
62 | private _reject?;
|
63 | private _promise;
|
64 | |
65 |
|
66 |
|
67 |
|
68 |
|
69 | constructor(ref: Reference, blob: FbsBlob, metadata?: Metadata | null);
|
70 | private _makeProgressCallback;
|
71 | private _shouldDoResumable;
|
72 | private _start;
|
73 | private _resolveToken;
|
74 | private _createResumable;
|
75 | private _fetchStatus;
|
76 | private _continueUpload;
|
77 | private _increaseMultiplier;
|
78 | private _fetchMetadata;
|
79 | private _oneShotUpload;
|
80 | private _updateProgress;
|
81 | private _transition;
|
82 | private completeTransitions_;
|
83 | /**
|
84 | * A snapshot of the current task state.
|
85 | */
|
86 | get snapshot(): UploadTaskSnapshot;
|
87 | /**
|
88 | * Adds a callback for an event.
|
89 | * @param type - The type of event to listen for.
|
90 | * @param nextOrObserver -
|
91 | * The `next` function, which gets called for each item in
|
92 | * the event stream, or an observer object with some or all of these three
|
93 | * properties (`next`, `error`, `complete`).
|
94 | * @param error - A function that gets called with a `FirebaseStorageError`
|
95 | * if the event stream ends due to an error.
|
96 | * @param completed - A function that gets called if the
|
97 | * event stream ends normally.
|
98 | * @returns
|
99 | * If only the event argument is passed, returns a function you can use to
|
100 | * add callbacks (see the examples above). If more than just the event
|
101 | * argument is passed, returns a function you can call to unregister the
|
102 | * callbacks.
|
103 | */
|
104 | on(type: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | ((a: UploadTaskSnapshot) => unknown), error?: ErrorFn, completed?: CompleteFn): Unsubscribe | Subscribe<UploadTaskSnapshot>;
|
105 | /**
|
106 | * This object behaves like a Promise, and resolves with its snapshot data
|
107 | * when the upload completes.
|
108 | * @param onFulfilled - The fulfillment callback. Promise chaining works as normal.
|
109 | * @param onRejected - The rejection callback.
|
110 | */
|
111 | then<U>(onFulfilled?: ((value: UploadTaskSnapshot) => U | Promise<U>) | null, onRejected?: ((error: FirebaseStorageError) => U | Promise<U>) | null): Promise<U>;
|
112 | /**
|
113 | * Equivalent to calling `then(null, onRejected)`.
|
114 | */
|
115 | catch<T>(onRejected: (p1: FirebaseStorageError) => T | Promise<T>): Promise<T>;
|
116 | /**
|
117 | * Adds the given observer.
|
118 | */
|
119 | private _addObserver;
|
120 | /**
|
121 | * Removes the given observer.
|
122 | */
|
123 | private _removeObserver;
|
124 | private _notifyObservers;
|
125 | private _finishPromise;
|
126 | private _notifyObserver;
|
127 | /**
|
128 | * Resumes a paused task. Has no effect on a currently running or failed task.
|
129 | * @returns True if the operation took effect, false if ignored.
|
130 | */
|
131 | resume(): boolean;
|
132 | /**
|
133 | * Pauses a currently running task. Has no effect on a paused or failed task.
|
134 | * @returns True if the operation took effect, false if ignored.
|
135 | */
|
136 | pause(): boolean;
|
137 | /**
|
138 | * Cancels a currently running or paused task. Has no effect on a complete or
|
139 | * failed task.
|
140 | * @returns True if the operation took effect, false if ignored.
|
141 | */
|
142 | cancel(): boolean;
|
143 | }
|