storage.d.ts 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392
  1. /**
  2. * Cloud Storage for Firebase
  3. *
  4. * @packageDocumentation
  5. */
  6. /// <reference types="node" />
  7. import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
  8. import { CompleteFn } from '@firebase/util';
  9. import { EmulatorMockTokenOptions } from '@firebase/util';
  10. import { FirebaseApp } from '@firebase/app';
  11. import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
  12. import { FirebaseError } from '@firebase/util';
  13. import { _FirebaseService } from '@firebase/app';
  14. import { NextFn } from '@firebase/util';
  15. import { Provider } from '@firebase/component';
  16. import { Subscribe } from '@firebase/util';
  17. import { Unsubscribe } from '@firebase/util';
  18. /**
  19. * A function that is called if the event stream ends normally.
  20. */
  21. declare type CompleteFn_2 = () => void;
  22. /**
  23. * A lightweight wrapper around XMLHttpRequest with a
  24. * goog.net.XhrIo-like interface.
  25. *
  26. * You can create a new connection by invoking `newTextConnection()`,
  27. * `newBytesConnection()` or `newStreamConnection()`.
  28. */
  29. declare interface Connection<T extends ConnectionType> {
  30. /**
  31. * Sends a request to the provided URL.
  32. *
  33. * This method never rejects its promise. In case of encountering an error,
  34. * it sets an error code internally which can be accessed by calling
  35. * getErrorCode() by callers.
  36. */
  37. send(url: string, method: string, body?: ArrayBufferView | Blob | string | null, headers?: Headers_2): Promise<void>;
  38. getErrorCode(): ErrorCode;
  39. getStatus(): number;
  40. getResponse(): T;
  41. getErrorText(): string;
  42. /**
  43. * Abort the request.
  44. */
  45. abort(): void;
  46. getResponseHeader(header: string): string | null;
  47. addUploadProgressListener(listener: (p1: ProgressEvent) => void): void;
  48. removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void;
  49. }
  50. /** Response type exposed by the networking APIs. */
  51. declare type ConnectionType = string | ArrayBuffer | Blob | NodeJS.ReadableStream;
  52. /**
  53. * Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator.
  54. *
  55. * @param storage - The {@link FirebaseStorage} instance
  56. * @param host - The emulator host (ex: localhost)
  57. * @param port - The emulator port (ex: 5001)
  58. * @param options - Emulator options. `options.mockUserToken` is the mock auth
  59. * token to use for unit testing Security Rules.
  60. * @public
  61. */
  62. export declare function connectStorageEmulator(storage: FirebaseStorage, host: string, port: number, options?: {
  63. mockUserToken?: EmulatorMockTokenOptions | string;
  64. }): void;
  65. /**
  66. * @internal
  67. */
  68. export declare function _dataFromString(format: StringFormat, stringData: string): StringData;
  69. /**
  70. * Deletes the object at this location.
  71. * @public
  72. * @param ref - {@link StorageReference} for object to delete.
  73. * @returns A `Promise` that resolves if the deletion succeeds.
  74. */
  75. export declare function deleteObject(ref: StorageReference): Promise<void>;
  76. export { EmulatorMockTokenOptions }
  77. /**
  78. * Error codes for requests made by the the XhrIo wrapper.
  79. */
  80. declare enum ErrorCode {
  81. NO_ERROR = 0,
  82. NETWORK_ERROR = 1,
  83. ABORT = 2
  84. }
  85. /**
  86. * A function that is called with a `StorageError`
  87. * if the event stream ends due to an error.
  88. */
  89. declare type ErrorFn = (error: StorageError) => void;
  90. /** A function to handle an error. */
  91. declare type ErrorHandler = (connection: Connection<ConnectionType>, response: StorageError) => StorageError;
  92. /**
  93. * @license
  94. * Copyright 2017 Google LLC
  95. *
  96. * Licensed under the Apache License, Version 2.0 (the "License");
  97. * you may not use this file except in compliance with the License.
  98. * You may obtain a copy of the License at
  99. *
  100. * http://www.apache.org/licenses/LICENSE-2.0
  101. *
  102. * Unless required by applicable law or agreed to in writing, software
  103. * distributed under the License is distributed on an "AS IS" BASIS,
  104. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  105. * See the License for the specific language governing permissions and
  106. * limitations under the License.
  107. */
  108. /**
  109. * @param opt_elideCopy - If true, doesn't copy mutable input data
  110. * (e.g. Uint8Arrays). Pass true only if you know the objects will not be
  111. * modified after this blob's construction.
  112. *
  113. * @internal
  114. */
  115. export declare class _FbsBlob {
  116. private data_;
  117. private size_;
  118. private type_;
  119. constructor(data: Blob | Uint8Array | ArrayBuffer, elideCopy?: boolean);
  120. size(): number;
  121. type(): string;
  122. slice(startByte: number, endByte: number): _FbsBlob | null;
  123. static getBlob(...args: Array<string | _FbsBlob>): _FbsBlob | null;
  124. uploadData(): Blob | Uint8Array;
  125. }
  126. /**
  127. * A Firebase Storage instance.
  128. * @public
  129. */
  130. export declare interface FirebaseStorage extends _FirebaseService {
  131. /**
  132. * The {@link @firebase/app#FirebaseApp} associated with this `FirebaseStorage` instance.
  133. */
  134. readonly app: FirebaseApp;
  135. /**
  136. * The maximum time to retry uploads in milliseconds.
  137. */
  138. maxUploadRetryTime: number;
  139. /**
  140. * The maximum time to retry operations other than uploads or downloads in
  141. * milliseconds.
  142. */
  143. maxOperationRetryTime: number;
  144. }
  145. /**
  146. * A service that provides Firebase Storage Reference instances.
  147. * @param opt_url - gs:// url to a custom Storage Bucket
  148. *
  149. * @internal
  150. */
  151. export declare class _FirebaseStorageImpl implements FirebaseStorage {
  152. /**
  153. * FirebaseApp associated with this StorageService instance.
  154. */
  155. readonly app: FirebaseApp;
  156. readonly _authProvider: Provider<FirebaseAuthInternalName>;
  157. /**
  158. * @internal
  159. */
  160. readonly _appCheckProvider: Provider<AppCheckInternalComponentName>;
  161. /**
  162. * @internal
  163. */
  164. readonly _url?: string | undefined;
  165. readonly _firebaseVersion?: string | undefined;
  166. _bucket: _Location | null;
  167. /**
  168. * This string can be in the formats:
  169. * - host
  170. * - host:port
  171. */
  172. private _host;
  173. _protocol: string;
  174. protected readonly _appId: string | null;
  175. private readonly _requests;
  176. private _deleted;
  177. private _maxOperationRetryTime;
  178. private _maxUploadRetryTime;
  179. _overrideAuthToken?: string;
  180. constructor(
  181. /**
  182. * FirebaseApp associated with this StorageService instance.
  183. */
  184. app: FirebaseApp, _authProvider: Provider<FirebaseAuthInternalName>,
  185. /**
  186. * @internal
  187. */
  188. _appCheckProvider: Provider<AppCheckInternalComponentName>,
  189. /**
  190. * @internal
  191. */
  192. _url?: string | undefined, _firebaseVersion?: string | undefined);
  193. /**
  194. * The host string for this service, in the form of `host` or
  195. * `host:port`.
  196. */
  197. get host(): string;
  198. set host(host: string);
  199. /**
  200. * The maximum time to retry uploads in milliseconds.
  201. */
  202. get maxUploadRetryTime(): number;
  203. set maxUploadRetryTime(time: number);
  204. /**
  205. * The maximum time to retry operations other than uploads or downloads in
  206. * milliseconds.
  207. */
  208. get maxOperationRetryTime(): number;
  209. set maxOperationRetryTime(time: number);
  210. _getAuthToken(): Promise<string | null>;
  211. _getAppCheckToken(): Promise<string | null>;
  212. /**
  213. * Stop running requests and prevent more from being created.
  214. */
  215. _delete(): Promise<void>;
  216. /**
  217. * Returns a new firebaseStorage.Reference object referencing this StorageService
  218. * at the given Location.
  219. */
  220. _makeStorageReference(loc: _Location): _Reference;
  221. /**
  222. * @param requestInfo - HTTP RequestInfo object
  223. * @param authToken - Firebase auth token
  224. */
  225. _makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo_2<I, O>, requestFactory: () => Connection<I>, authToken: string | null, appCheckToken: string | null, retry?: boolean): Request_2<O>;
  226. makeRequestWithTokens<I extends ConnectionType, O>(requestInfo: RequestInfo_2<I, O>, requestFactory: () => Connection<I>): Promise<O>;
  227. }
  228. /**
  229. * The full set of object metadata, including read-only properties.
  230. * @public
  231. */
  232. export declare interface FullMetadata extends UploadMetadata {
  233. /**
  234. * The bucket this object is contained in.
  235. */
  236. bucket: string;
  237. /**
  238. * The full path of this object.
  239. */
  240. fullPath: string;
  241. /**
  242. * The object's generation.
  243. * {@link https://cloud.google.com/storage/docs/metadata#generation-number}
  244. */
  245. generation: string;
  246. /**
  247. * The object's metageneration.
  248. * {@link https://cloud.google.com/storage/docs/metadata#generation-number}
  249. */
  250. metageneration: string;
  251. /**
  252. * The short name of this object, which is the last component of the full path.
  253. * For example, if fullPath is 'full/path/image.png', name is 'image.png'.
  254. */
  255. name: string;
  256. /**
  257. * The size of this object, in bytes.
  258. */
  259. size: number;
  260. /**
  261. * A date string representing when this object was created.
  262. */
  263. timeCreated: string;
  264. /**
  265. * A date string representing when this object was last updated.
  266. */
  267. updated: string;
  268. /**
  269. * Tokens to allow access to the downloatd URL.
  270. */
  271. downloadTokens: string[] | undefined;
  272. /**
  273. * `StorageReference` associated with this upload.
  274. */
  275. ref?: StorageReference | undefined;
  276. }
  277. /**
  278. * Downloads the data at the object's location. Returns an error if the object
  279. * is not found.
  280. *
  281. * To use this functionality, you have to whitelist your app's origin in your
  282. * Cloud Storage bucket. See also
  283. * https://cloud.google.com/storage/docs/configuring-cors
  284. *
  285. * This API is not available in Node.
  286. *
  287. * @public
  288. * @param ref - StorageReference where data should be downloaded.
  289. * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
  290. * retrieve.
  291. * @returns A Promise that resolves with a Blob containing the object's bytes
  292. */
  293. export declare function getBlob(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<Blob>;
  294. /**
  295. * Downloads the data at the object's location. Returns an error if the object
  296. * is not found.
  297. *
  298. * To use this functionality, you have to whitelist your app's origin in your
  299. * Cloud Storage bucket. See also
  300. * https://cloud.google.com/storage/docs/configuring-cors
  301. *
  302. * @public
  303. * @param ref - StorageReference where data should be downloaded.
  304. * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
  305. * retrieve.
  306. * @returns A Promise containing the object's bytes
  307. */
  308. export declare function getBytes(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<ArrayBuffer>;
  309. /**
  310. * @internal
  311. */
  312. export declare function _getChild(ref: StorageReference, childPath: string): _Reference;
  313. /**
  314. * Returns the download URL for the given {@link StorageReference}.
  315. * @public
  316. * @param ref - {@link StorageReference} to get the download URL for.
  317. * @returns A `Promise` that resolves with the download
  318. * URL for this object.
  319. */
  320. export declare function getDownloadURL(ref: StorageReference): Promise<string>;
  321. /**
  322. * A `Promise` that resolves with the metadata for this object. If this
  323. * object doesn't exist or metadata cannot be retreived, the promise is
  324. * rejected.
  325. * @public
  326. * @param ref - {@link StorageReference} to get metadata from.
  327. */
  328. export declare function getMetadata(ref: StorageReference): Promise<FullMetadata>;
  329. /**
  330. * Gets a {@link FirebaseStorage} instance for the given Firebase app.
  331. * @public
  332. * @param app - Firebase app to get {@link FirebaseStorage} instance for.
  333. * @param bucketUrl - The gs:// url to your Firebase Storage Bucket.
  334. * If not passed, uses the app's default Storage Bucket.
  335. * @returns A {@link FirebaseStorage} instance.
  336. */
  337. export declare function getStorage(app?: FirebaseApp, bucketUrl?: string): FirebaseStorage;
  338. /**
  339. * Downloads the data at the object's location. Raises an error event if the
  340. * object is not found.
  341. *
  342. * This API is only available in Node.
  343. *
  344. * @public
  345. * @param ref - StorageReference where data should be downloaded.
  346. * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
  347. * retrieve.
  348. * @returns A stream with the object's data as bytes
  349. */
  350. export declare function getStream(ref: StorageReference, maxDownloadSizeBytes?: number): NodeJS.ReadableStream;
  351. /**
  352. * @license
  353. * Copyright 2017 Google LLC
  354. *
  355. * Licensed under the Apache License, Version 2.0 (the "License");
  356. * you may not use this file except in compliance with the License.
  357. * You may obtain a copy of the License at
  358. *
  359. * http://www.apache.org/licenses/LICENSE-2.0
  360. *
  361. * Unless required by applicable law or agreed to in writing, software
  362. * distributed under the License is distributed on an "AS IS" BASIS,
  363. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  364. * See the License for the specific language governing permissions and
  365. * limitations under the License.
  366. */
  367. /// <reference types="node" />
  368. /** Network headers */
  369. declare type Headers_2 = Record<string, string>;
  370. /**
  371. * Internal enum for task state.
  372. */
  373. declare const enum InternalTaskState {
  374. RUNNING = "running",
  375. PAUSING = "pausing",
  376. PAUSED = "paused",
  377. SUCCESS = "success",
  378. CANCELING = "canceling",
  379. CANCELED = "canceled",
  380. ERROR = "error"
  381. }
  382. /**
  383. * @internal
  384. */
  385. export declare function _invalidArgument(message: string): StorageError;
  386. /**
  387. * @param name - The name of the operation that was invalid.
  388. *
  389. * @internal
  390. */
  391. export declare function _invalidRootOperation(name: string): StorageError;
  392. /**
  393. * List items (files) and prefixes (folders) under this storage reference.
  394. *
  395. * List API is only available for Firebase Rules Version 2.
  396. *
  397. * GCS is a key-blob store. Firebase Storage imposes the semantic of '/'
  398. * delimited folder structure.
  399. * Refer to GCS's List API if you want to learn more.
  400. *
  401. * To adhere to Firebase Rules's Semantics, Firebase Storage does not
  402. * support objects whose paths end with "/" or contain two consecutive
  403. * "/"s. Firebase Storage List API will filter these unsupported objects.
  404. * list() may fail if there are too many unsupported objects in the bucket.
  405. * @public
  406. *
  407. * @param ref - {@link StorageReference} to get list from.
  408. * @param options - See {@link ListOptions} for details.
  409. * @returns A `Promise` that resolves with the items and prefixes.
  410. * `prefixes` contains references to sub-folders and `items`
  411. * contains references to objects in this folder. `nextPageToken`
  412. * can be used to get the rest of the results.
  413. */
  414. export declare function list(ref: StorageReference, options?: ListOptions): Promise<ListResult>;
  415. /**
  416. * List all items (files) and prefixes (folders) under this storage reference.
  417. *
  418. * This is a helper method for calling list() repeatedly until there are
  419. * no more results. The default pagination size is 1000.
  420. *
  421. * Note: The results may not be consistent if objects are changed while this
  422. * operation is running.
  423. *
  424. * Warning: `listAll` may potentially consume too many resources if there are
  425. * too many results.
  426. * @public
  427. * @param ref - {@link StorageReference} to get list from.
  428. *
  429. * @returns A `Promise` that resolves with all the items and prefixes under
  430. * the current storage reference. `prefixes` contains references to
  431. * sub-directories and `items` contains references to objects in this
  432. * folder. `nextPageToken` is never returned.
  433. */
  434. export declare function listAll(ref: StorageReference): Promise<ListResult>;
  435. /**
  436. * The options `list()` accepts.
  437. * @public
  438. */
  439. export declare interface ListOptions {
  440. /**
  441. * If set, limits the total number of `prefixes` and `items` to return.
  442. * The default and maximum maxResults is 1000.
  443. */
  444. maxResults?: number | null;
  445. /**
  446. * The `nextPageToken` from a previous call to `list()`. If provided,
  447. * listing is resumed from the previous position.
  448. */
  449. pageToken?: string | null;
  450. }
  451. /**
  452. * Result returned by list().
  453. * @public
  454. */
  455. export declare interface ListResult {
  456. /**
  457. * References to prefixes (sub-folders). You can call list() on them to
  458. * get its contents.
  459. *
  460. * Folders are implicit based on '/' in the object paths.
  461. * For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a')
  462. * will return '/a/b' as a prefix.
  463. */
  464. prefixes: StorageReference[];
  465. /**
  466. * Objects in this directory.
  467. * You can call getMetadata() and getDownloadUrl() on them.
  468. */
  469. items: StorageReference[];
  470. /**
  471. * If set, there might be more results for this list. Use this token to resume the list.
  472. */
  473. nextPageToken?: string;
  474. }
  475. /**
  476. * @license
  477. * Copyright 2017 Google LLC
  478. *
  479. * Licensed under the Apache License, Version 2.0 (the "License");
  480. * you may not use this file except in compliance with the License.
  481. * You may obtain a copy of the License at
  482. *
  483. * http://www.apache.org/licenses/LICENSE-2.0
  484. *
  485. * Unless required by applicable law or agreed to in writing, software
  486. * distributed under the License is distributed on an "AS IS" BASIS,
  487. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  488. * See the License for the specific language governing permissions and
  489. * limitations under the License.
  490. */
  491. /**
  492. * Firebase Storage location data.
  493. *
  494. * @internal
  495. */
  496. export declare class _Location {
  497. readonly bucket: string;
  498. private path_;
  499. constructor(bucket: string, path: string);
  500. get path(): string;
  501. get isRoot(): boolean;
  502. fullServerUrl(): string;
  503. bucketOnlyServerUrl(): string;
  504. static makeFromBucketSpec(bucketString: string, host: string): _Location;
  505. static makeFromUrl(url: string, host: string): _Location;
  506. }
  507. /**
  508. * @fileoverview Documentation for the metadata format.
  509. */
  510. /**
  511. * The full set of object metadata, including read-only properties.
  512. */
  513. declare interface Metadata extends FullMetadata {
  514. [prop: string]: unknown;
  515. }
  516. /**
  517. * Function that is called once for each value in a stream of values.
  518. */
  519. declare type NextFn_2<T> = (value: T) => void;
  520. /**
  521. * Returns a {@link StorageReference} for the given url.
  522. * @param storage - {@link FirebaseStorage} instance.
  523. * @param url - URL. If empty, returns root reference.
  524. * @public
  525. */
  526. export declare function ref(storage: FirebaseStorage, url?: string): StorageReference;
  527. /**
  528. * Returns a {@link StorageReference} for the given path in the
  529. * default bucket.
  530. * @param storageOrRef - {@link FirebaseStorage} or {@link StorageReference}.
  531. * @param pathOrUrlStorage - path. If empty, returns root reference (if {@link FirebaseStorage}
  532. * instance provided) or returns same reference (if {@link StorageReference} provided).
  533. * @public
  534. */
  535. export declare function ref(storageOrRef: FirebaseStorage | StorageReference, path?: string): StorageReference;
  536. /**
  537. * Provides methods to interact with a bucket in the Firebase Storage service.
  538. * @internal
  539. * @param _location - An fbs.location, or the URL at
  540. * which to base this object, in one of the following forms:
  541. * gs://<bucket>/<object-path>
  542. * http[s]://firebasestorage.googleapis.com/
  543. * <api-version>/b/<bucket>/o/<object-path>
  544. * Any query or fragment strings will be ignored in the http[s]
  545. * format. If no value is passed, the storage object will use a URL based on
  546. * the project ID of the base firebase.App instance.
  547. */
  548. export declare class _Reference {
  549. private _service;
  550. _location: _Location;
  551. constructor(_service: _FirebaseStorageImpl, location: string | _Location);
  552. /**
  553. * Returns the URL for the bucket and path this object references,
  554. * in the form gs://<bucket>/<object-path>
  555. * @override
  556. */
  557. toString(): string;
  558. protected _newRef(service: _FirebaseStorageImpl, location: _Location): _Reference;
  559. /**
  560. * A reference to the root of this object's bucket.
  561. */
  562. get root(): _Reference;
  563. /**
  564. * The name of the bucket containing this reference's object.
  565. */
  566. get bucket(): string;
  567. /**
  568. * The full path of this object.
  569. */
  570. get fullPath(): string;
  571. /**
  572. * The short name of this object, which is the last component of the full path.
  573. * For example, if fullPath is 'full/path/image.png', name is 'image.png'.
  574. */
  575. get name(): string;
  576. /**
  577. * The `StorageService` instance this `StorageReference` is associated with.
  578. */
  579. get storage(): _FirebaseStorageImpl;
  580. /**
  581. * A `StorageReference` pointing to the parent location of this `StorageReference`, or null if
  582. * this reference is the root.
  583. */
  584. get parent(): _Reference | null;
  585. /**
  586. * Utility function to throw an error in methods that do not accept a root reference.
  587. */
  588. _throwIfRoot(name: string): void;
  589. }
  590. declare interface Request_2<T> {
  591. getPromise(): Promise<T>;
  592. /**
  593. * Cancels the request. IMPORTANT: the promise may still be resolved with an
  594. * appropriate value (if the request is finished before you call this method,
  595. * but the promise has not yet been resolved), so don't just assume it will be
  596. * rejected if you call this function.
  597. * @param appDelete - True if the cancelation came from the app being deleted.
  598. */
  599. cancel(appDelete?: boolean): void;
  600. }
  601. /**
  602. * A function that converts a server response to the API type expected by the
  603. * SDK.
  604. *
  605. * @param I - the type of the backend's network response
  606. * @param O - the output response type used by the rest of the SDK.
  607. */
  608. declare type RequestHandler<I extends ConnectionType, O> = (connection: Connection<I>, response: I) => O;
  609. /**
  610. * Contains a fully specified request.
  611. *
  612. * @param I - the type of the backend's network response.
  613. * @param O - the output response type used by the rest of the SDK.
  614. */
  615. declare class RequestInfo_2<I extends ConnectionType, O> {
  616. url: string;
  617. method: string;
  618. /**
  619. * Returns the value with which to resolve the request's promise. Only called
  620. * if the request is successful. Throw from this function to reject the
  621. * returned Request's promise with the thrown error.
  622. * Note: The XhrIo passed to this function may be reused after this callback
  623. * returns. Do not keep a reference to it in any way.
  624. */
  625. handler: RequestHandler<I, O>;
  626. timeout: number;
  627. urlParams: UrlParams;
  628. headers: Headers_2;
  629. body: Blob | string | Uint8Array | null;
  630. errorHandler: ErrorHandler | null;
  631. /**
  632. * Called with the current number of bytes uploaded and total size (-1 if not
  633. * computable) of the request body (i.e. used to report upload progress).
  634. */
  635. progressCallback: ((p1: number, p2: number) => void) | null;
  636. successCodes: number[];
  637. additionalRetryCodes: number[];
  638. constructor(url: string, method: string,
  639. /**
  640. * Returns the value with which to resolve the request's promise. Only called
  641. * if the request is successful. Throw from this function to reject the
  642. * returned Request's promise with the thrown error.
  643. * Note: The XhrIo passed to this function may be reused after this callback
  644. * returns. Do not keep a reference to it in any way.
  645. */
  646. handler: RequestHandler<I, O>, timeout: number);
  647. }
  648. /**
  649. * Object metadata that can be set at any time.
  650. * @public
  651. */
  652. export declare interface SettableMetadata {
  653. /**
  654. * Served as the 'Cache-Control' header on object download.
  655. */
  656. cacheControl?: string | undefined;
  657. /**
  658. * Served as the 'Content-Disposition' header on object download.
  659. */
  660. contentDisposition?: string | undefined;
  661. /**
  662. * Served as the 'Content-Encoding' header on object download.
  663. */
  664. contentEncoding?: string | undefined;
  665. /**
  666. * Served as the 'Content-Language' header on object download.
  667. */
  668. contentLanguage?: string | undefined;
  669. /**
  670. * Served as the 'Content-Type' header on object download.
  671. */
  672. contentType?: string | undefined;
  673. /**
  674. * Additional user-defined custom metadata.
  675. */
  676. customMetadata?: {
  677. [key: string]: string;
  678. } | undefined;
  679. }
  680. /**
  681. * An error returned by the Firebase Storage SDK.
  682. * @public
  683. */
  684. export declare class StorageError extends FirebaseError {
  685. private status_;
  686. private readonly _baseMessage;
  687. /**
  688. * Stores custom error data unique to the `StorageError`.
  689. */
  690. customData: {
  691. serverResponse: string | null;
  692. };
  693. /**
  694. * @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and
  695. * added to the end of the message.
  696. * @param message - Error message.
  697. * @param status_ - Corresponding HTTP Status Code
  698. */
  699. constructor(code: StorageErrorCode, message: string, status_?: number);
  700. get status(): number;
  701. set status(status: number);
  702. /**
  703. * Compares a `StorageErrorCode` against this error's code, filtering out the prefix.
  704. */
  705. _codeEquals(code: StorageErrorCode): boolean;
  706. /**
  707. * Optional response message that was added by the server.
  708. */
  709. get serverResponse(): null | string;
  710. set serverResponse(serverResponse: string | null);
  711. }
  712. /**
  713. * @public
  714. * Error codes that can be attached to `StorageError` objects.
  715. */
  716. export declare enum StorageErrorCode {
  717. UNKNOWN = "unknown",
  718. OBJECT_NOT_FOUND = "object-not-found",
  719. BUCKET_NOT_FOUND = "bucket-not-found",
  720. PROJECT_NOT_FOUND = "project-not-found",
  721. QUOTA_EXCEEDED = "quota-exceeded",
  722. UNAUTHENTICATED = "unauthenticated",
  723. UNAUTHORIZED = "unauthorized",
  724. UNAUTHORIZED_APP = "unauthorized-app",
  725. RETRY_LIMIT_EXCEEDED = "retry-limit-exceeded",
  726. INVALID_CHECKSUM = "invalid-checksum",
  727. CANCELED = "canceled",
  728. INVALID_EVENT_NAME = "invalid-event-name",
  729. INVALID_URL = "invalid-url",
  730. INVALID_DEFAULT_BUCKET = "invalid-default-bucket",
  731. NO_DEFAULT_BUCKET = "no-default-bucket",
  732. CANNOT_SLICE_BLOB = "cannot-slice-blob",
  733. SERVER_FILE_WRONG_SIZE = "server-file-wrong-size",
  734. NO_DOWNLOAD_URL = "no-download-url",
  735. INVALID_ARGUMENT = "invalid-argument",
  736. INVALID_ARGUMENT_COUNT = "invalid-argument-count",
  737. APP_DELETED = "app-deleted",
  738. INVALID_ROOT_OPERATION = "invalid-root-operation",
  739. INVALID_FORMAT = "invalid-format",
  740. INTERNAL_ERROR = "internal-error",
  741. UNSUPPORTED_ENVIRONMENT = "unsupported-environment"
  742. }
  743. /**
  744. * A stream observer for Firebase Storage.
  745. * @public
  746. */
  747. export declare interface StorageObserver<T> {
  748. next?: NextFn<T> | null;
  749. error?: (error: StorageError) => void | null;
  750. complete?: CompleteFn | null;
  751. }
  752. /**
  753. * An observer identical to the `Observer` defined in packages/util except the
  754. * error passed into the ErrorFn is specifically a `StorageError`.
  755. */
  756. declare interface StorageObserver_2<T> {
  757. /**
  758. * Function that is called once for each value in the event stream.
  759. */
  760. next?: NextFn_2<T>;
  761. /**
  762. * A function that is called with a `StorageError`
  763. * if the event stream ends due to an error.
  764. */
  765. error?: ErrorFn;
  766. /**
  767. * A function that is called if the event stream ends normally.
  768. */
  769. complete?: CompleteFn_2;
  770. }
  771. /**
  772. * Represents a reference to a Google Cloud Storage object. Developers can
  773. * upload, download, and delete objects, as well as get/set object metadata.
  774. * @public
  775. */
  776. export declare interface StorageReference {
  777. /**
  778. * Returns a gs:// URL for this object in the form
  779. * `gs://<bucket>/<path>/<to>/<object>`
  780. * @returns The gs:// URL.
  781. */
  782. toString(): string;
  783. /**
  784. * A reference to the root of this object's bucket.
  785. */
  786. root: StorageReference;
  787. /**
  788. * The name of the bucket containing this reference's object.
  789. */
  790. bucket: string;
  791. /**
  792. * The full path of this object.
  793. */
  794. fullPath: string;
  795. /**
  796. * The short name of this object, which is the last component of the full path.
  797. * For example, if fullPath is 'full/path/image.png', name is 'image.png'.
  798. */
  799. name: string;
  800. /**
  801. * The {@link FirebaseStorage} instance associated with this reference.
  802. */
  803. storage: FirebaseStorage;
  804. /**
  805. * A reference pointing to the parent location of this reference, or null if
  806. * this reference is the root.
  807. */
  808. parent: StorageReference | null;
  809. }
  810. declare class StringData {
  811. data: Uint8Array;
  812. contentType: string | null;
  813. constructor(data: Uint8Array, contentType?: string | null);
  814. }
  815. /**
  816. * @license
  817. * Copyright 2017 Google LLC
  818. *
  819. * Licensed under the Apache License, Version 2.0 (the "License");
  820. * you may not use this file except in compliance with the License.
  821. * You may obtain a copy of the License at
  822. *
  823. * http://www.apache.org/licenses/LICENSE-2.0
  824. *
  825. * Unless required by applicable law or agreed to in writing, software
  826. * distributed under the License is distributed on an "AS IS" BASIS,
  827. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  828. * See the License for the specific language governing permissions and
  829. * limitations under the License.
  830. */
  831. /**
  832. * An enumeration of the possible string formats for upload.
  833. * @public
  834. */
  835. export declare type StringFormat = typeof StringFormat[keyof typeof StringFormat];
  836. /**
  837. * An enumeration of the possible string formats for upload.
  838. * @public
  839. */
  840. export declare const StringFormat: {
  841. /**
  842. * Indicates the string should be interpreted "raw", that is, as normal text.
  843. * The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte
  844. * sequence.
  845. * Example: The string 'Hello! \\ud83d\\ude0a' becomes the byte sequence
  846. * 48 65 6c 6c 6f 21 20 f0 9f 98 8a
  847. */
  848. readonly RAW: "raw";
  849. /**
  850. * Indicates the string should be interpreted as base64-encoded data.
  851. * Padding characters (trailing '='s) are optional.
  852. * Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence
  853. * ad 69 8e fb e1 3a b7 bf eb 97
  854. */
  855. readonly BASE64: "base64";
  856. /**
  857. * Indicates the string should be interpreted as base64url-encoded data.
  858. * Padding characters (trailing '='s) are optional.
  859. * Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence
  860. * ad 69 8e fb e1 3a b7 bf eb 97
  861. */
  862. readonly BASE64URL: "base64url";
  863. /**
  864. * Indicates the string is a data URL, such as one obtained from
  865. * canvas.toDataURL().
  866. * Example: the string 'data:application/octet-stream;base64,aaaa'
  867. * becomes the byte sequence
  868. * 69 a6 9a
  869. * (the content-type "application/octet-stream" is also applied, but can
  870. * be overridden in the metadata object).
  871. */
  872. readonly DATA_URL: "data_url";
  873. };
  874. /**
  875. * Subscribes to an event stream.
  876. */
  877. declare type Subscribe_2<T> = (next?: NextFn_2<T> | StorageObserver_2<T>, error?: ErrorFn, complete?: CompleteFn_2) => Unsubscribe_2;
  878. /**
  879. * An event that is triggered on a task.
  880. * @public
  881. */
  882. export declare type TaskEvent = 'state_changed';
  883. /**
  884. * @license
  885. * Copyright 2017 Google LLC
  886. *
  887. * Licensed under the Apache License, Version 2.0 (the "License");
  888. * you may not use this file except in compliance with the License.
  889. * You may obtain a copy of the License at
  890. *
  891. * http://www.apache.org/licenses/LICENSE-2.0
  892. *
  893. * Unless required by applicable law or agreed to in writing, software
  894. * distributed under the License is distributed on an "AS IS" BASIS,
  895. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  896. * See the License for the specific language governing permissions and
  897. * limitations under the License.
  898. */
  899. /**
  900. * @fileoverview Enumerations used for upload tasks.
  901. */
  902. /**
  903. * An event that is triggered on a task.
  904. * @internal
  905. */
  906. export declare type _TaskEvent = string;
  907. /**
  908. * An event that is triggered on a task.
  909. * @internal
  910. */
  911. export declare const _TaskEvent: {
  912. /**
  913. * For this event,
  914. * <ul>
  915. * <li>The `next` function is triggered on progress updates and when the
  916. * task is paused/resumed with an `UploadTaskSnapshot` as the first
  917. * argument.</li>
  918. * <li>The `error` function is triggered if the upload is canceled or fails
  919. * for another reason.</li>
  920. * <li>The `complete` function is triggered if the upload completes
  921. * successfully.</li>
  922. * </ul>
  923. */
  924. STATE_CHANGED: string;
  925. };
  926. /**
  927. * Represents the current state of a running upload.
  928. * @public
  929. */
  930. export declare type TaskState = 'running' | 'paused' | 'success' | 'canceled' | 'error';
  931. /**
  932. * Represents the current state of a running upload.
  933. * @internal
  934. */
  935. export declare type _TaskState = typeof _TaskState[keyof typeof _TaskState];
  936. /**
  937. * Represents the current state of a running upload.
  938. * @internal
  939. */
  940. export declare const _TaskState: {
  941. /** The task is currently transferring data. */
  942. readonly RUNNING: "running";
  943. /** The task was paused by the user. */
  944. readonly PAUSED: "paused";
  945. /** The task completed successfully. */
  946. readonly SUCCESS: "success";
  947. /** The task was canceled. */
  948. readonly CANCELED: "canceled";
  949. /** The task failed with an error. */
  950. readonly ERROR: "error";
  951. };
  952. /**
  953. * Unsubscribes from a stream.
  954. */
  955. declare type Unsubscribe_2 = () => void;
  956. /**
  957. * Updates the metadata for this object.
  958. * @public
  959. * @param ref - {@link StorageReference} to update metadata for.
  960. * @param metadata - The new metadata for the object.
  961. * Only values that have been explicitly set will be changed. Explicitly
  962. * setting a value to null will remove the metadata.
  963. * @returns A `Promise` that resolves with the new metadata for this object.
  964. */
  965. export declare function updateMetadata(ref: StorageReference, metadata: SettableMetadata): Promise<FullMetadata>;
  966. /**
  967. * Uploads data to this object's location.
  968. * The upload is not resumable.
  969. * @public
  970. * @param ref - {@link StorageReference} where data should be uploaded.
  971. * @param data - The data to upload.
  972. * @param metadata - Metadata for the data to upload.
  973. * @returns A Promise containing an UploadResult
  974. */
  975. export declare function uploadBytes(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): Promise<UploadResult>;
  976. /**
  977. * Uploads data to this object's location.
  978. * The upload can be paused and resumed, and exposes progress updates.
  979. * @public
  980. * @param ref - {@link StorageReference} where data should be uploaded.
  981. * @param data - The data to upload.
  982. * @param metadata - Metadata for the data to upload.
  983. * @returns An UploadTask
  984. */
  985. export declare function uploadBytesResumable(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): UploadTask;
  986. /**
  987. * Object metadata that can be set at upload.
  988. * @public
  989. */
  990. export declare interface UploadMetadata extends SettableMetadata {
  991. /**
  992. * A Base64-encoded MD5 hash of the object being uploaded.
  993. */
  994. md5Hash?: string | undefined;
  995. }
  996. /**
  997. * Result returned from a non-resumable upload.
  998. * @public
  999. */
  1000. export declare interface UploadResult {
  1001. /**
  1002. * Contains the metadata sent back from the server.
  1003. */
  1004. readonly metadata: FullMetadata;
  1005. /**
  1006. * The reference that spawned this upload.
  1007. */
  1008. readonly ref: StorageReference;
  1009. }
  1010. /**
  1011. * Uploads a string to this object's location.
  1012. * The upload is not resumable.
  1013. * @public
  1014. * @param ref - {@link StorageReference} where string should be uploaded.
  1015. * @param value - The string to upload.
  1016. * @param format - The format of the string to upload.
  1017. * @param metadata - Metadata for the string to upload.
  1018. * @returns A Promise containing an UploadResult
  1019. */
  1020. export declare function uploadString(ref: StorageReference, value: string, format?: StringFormat, metadata?: UploadMetadata): Promise<UploadResult>;
  1021. /**
  1022. * Represents the process of uploading an object. Allows you to monitor and
  1023. * manage the upload.
  1024. * @public
  1025. */
  1026. export declare interface UploadTask {
  1027. /**
  1028. * Cancels a running task. Has no effect on a complete or failed task.
  1029. * @returns True if the cancel had an effect.
  1030. */
  1031. cancel(): boolean;
  1032. /**
  1033. * Equivalent to calling `then(null, onRejected)`.
  1034. */
  1035. catch(onRejected: (error: StorageError) => unknown): Promise<unknown>;
  1036. /**
  1037. * Listens for events on this task.
  1038. *
  1039. * Events have three callback functions (referred to as `next`, `error`, and
  1040. * `complete`).
  1041. *
  1042. * If only the event is passed, a function that can be used to register the
  1043. * callbacks is returned. Otherwise, the callbacks are passed after the event.
  1044. *
  1045. * Callbacks can be passed either as three separate arguments <em>or</em> as the
  1046. * `next`, `error`, and `complete` properties of an object. Any of the three
  1047. * callbacks is optional, as long as at least one is specified. In addition,
  1048. * when you add your callbacks, you get a function back. You can call this
  1049. * function to unregister the associated callbacks.
  1050. *
  1051. * @example **Pass callbacks separately or in an object.**
  1052. * ```javascript
  1053. * var next = function(snapshot) {};
  1054. * var error = function(error) {};
  1055. * var complete = function() {};
  1056. *
  1057. * // The first example.
  1058. * uploadTask.on(
  1059. * firebase.storage.TaskEvent.STATE_CHANGED,
  1060. * next,
  1061. * error,
  1062. * complete);
  1063. *
  1064. * // This is equivalent to the first example.
  1065. * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, {
  1066. * 'next': next,
  1067. * 'error': error,
  1068. * 'complete': complete
  1069. * });
  1070. *
  1071. * // This is equivalent to the first example.
  1072. * var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
  1073. * subscribe(next, error, complete);
  1074. *
  1075. * // This is equivalent to the first example.
  1076. * var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
  1077. * subscribe({
  1078. * 'next': next,
  1079. * 'error': error,
  1080. * 'complete': complete
  1081. * });
  1082. * ```
  1083. *
  1084. * @example **Any callback is optional.**
  1085. * ```javascript
  1086. * // Just listening for completion, this is legal.
  1087. * uploadTask.on(
  1088. * firebase.storage.TaskEvent.STATE_CHANGED,
  1089. * null,
  1090. * null,
  1091. * function() {
  1092. * console.log('upload complete!');
  1093. * });
  1094. *
  1095. * // Just listening for progress/state changes, this is legal.
  1096. * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, function(snapshot) {
  1097. * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
  1098. * console.log(percent + "% done");
  1099. * });
  1100. *
  1101. * // This is also legal.
  1102. * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, {
  1103. * 'complete': function() {
  1104. * console.log('upload complete!');
  1105. * }
  1106. * });
  1107. * ```
  1108. *
  1109. * @example **Use the returned function to remove callbacks.**
  1110. * ```javascript
  1111. * var unsubscribe = uploadTask.on(
  1112. * firebase.storage.TaskEvent.STATE_CHANGED,
  1113. * function(snapshot) {
  1114. * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
  1115. * console.log(percent + "% done");
  1116. * // Stop after receiving one update.
  1117. * unsubscribe();
  1118. * });
  1119. *
  1120. * // This code is equivalent to the above.
  1121. * var handle = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
  1122. * unsubscribe = handle(function(snapshot) {
  1123. * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
  1124. * console.log(percent + "% done");
  1125. * // Stop after receiving one update.
  1126. * unsubscribe();
  1127. * });
  1128. * ```
  1129. *
  1130. * @param event - The type of event to listen for.
  1131. * @param nextOrObserver -
  1132. * The `next` function, which gets called for each item in
  1133. * the event stream, or an observer object with some or all of these three
  1134. * properties (`next`, `error`, `complete`).
  1135. * @param error - A function that gets called with a `StorageError`
  1136. * if the event stream ends due to an error.
  1137. * @param completed - A function that gets called if the
  1138. * event stream ends normally.
  1139. * @returns
  1140. * If only the event argument is passed, returns a function you can use to
  1141. * add callbacks (see the examples above). If more than just the event
  1142. * argument is passed, returns a function you can call to unregister the
  1143. * callbacks.
  1144. */
  1145. on(event: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, complete?: Unsubscribe | null): Unsubscribe | Subscribe<UploadTaskSnapshot>;
  1146. /**
  1147. * Pauses a currently running task. Has no effect on a paused or failed task.
  1148. * @returns True if the operation took effect, false if ignored.
  1149. */
  1150. pause(): boolean;
  1151. /**
  1152. * Resumes a paused task. Has no effect on a currently running or failed task.
  1153. * @returns True if the operation took effect, false if ignored.
  1154. */
  1155. resume(): boolean;
  1156. /**
  1157. * A snapshot of the current task state.
  1158. */
  1159. snapshot: UploadTaskSnapshot;
  1160. /**
  1161. * This object behaves like a Promise, and resolves with its snapshot data
  1162. * when the upload completes.
  1163. * @param onFulfilled - The fulfillment callback. Promise chaining works as normal.
  1164. * @param onRejected - The rejection callback.
  1165. */
  1166. then(onFulfilled?: ((snapshot: UploadTaskSnapshot) => unknown) | null, onRejected?: ((error: StorageError) => unknown) | null): Promise<unknown>;
  1167. }
  1168. /**
  1169. * Represents a blob being uploaded. Can be used to pause/resume/cancel the
  1170. * upload and manage callbacks for various events.
  1171. * @internal
  1172. */
  1173. export declare class _UploadTask {
  1174. private _ref;
  1175. /**
  1176. * The data to be uploaded.
  1177. */
  1178. _blob: _FbsBlob;
  1179. /**
  1180. * Metadata related to the upload.
  1181. */
  1182. _metadata: Metadata | null;
  1183. private _mappings;
  1184. /**
  1185. * Number of bytes transferred so far.
  1186. */
  1187. _transferred: number;
  1188. private _needToFetchStatus;
  1189. private _needToFetchMetadata;
  1190. private _observers;
  1191. private _resumable;
  1192. /**
  1193. * Upload state.
  1194. */
  1195. _state: InternalTaskState;
  1196. private _error?;
  1197. private _uploadUrl?;
  1198. private _request?;
  1199. private _chunkMultiplier;
  1200. private _errorHandler;
  1201. private _metadataErrorHandler;
  1202. private _resolve?;
  1203. private _reject?;
  1204. private pendingTimeout?;
  1205. private _promise;
  1206. private sleepTime;
  1207. private maxSleepTime;
  1208. isExponentialBackoffExpired(): boolean;
  1209. /**
  1210. * @param ref - The firebaseStorage.Reference object this task came
  1211. * from, untyped to avoid cyclic dependencies.
  1212. * @param blob - The blob to upload.
  1213. */
  1214. constructor(ref: _Reference, blob: _FbsBlob, metadata?: Metadata | null);
  1215. private _makeProgressCallback;
  1216. private _shouldDoResumable;
  1217. private _start;
  1218. private _resolveToken;
  1219. private _createResumable;
  1220. private _fetchStatus;
  1221. private _continueUpload;
  1222. private _increaseMultiplier;
  1223. private _fetchMetadata;
  1224. private _oneShotUpload;
  1225. private _updateProgress;
  1226. private _transition;
  1227. private completeTransitions_;
  1228. /**
  1229. * A snapshot of the current task state.
  1230. */
  1231. get snapshot(): UploadTaskSnapshot;
  1232. /**
  1233. * Adds a callback for an event.
  1234. * @param type - The type of event to listen for.
  1235. * @param nextOrObserver -
  1236. * The `next` function, which gets called for each item in
  1237. * the event stream, or an observer object with some or all of these three
  1238. * properties (`next`, `error`, `complete`).
  1239. * @param error - A function that gets called with a `StorageError`
  1240. * if the event stream ends due to an error.
  1241. * @param completed - A function that gets called if the
  1242. * event stream ends normally.
  1243. * @returns
  1244. * If only the event argument is passed, returns a function you can use to
  1245. * add callbacks (see the examples above). If more than just the event
  1246. * argument is passed, returns a function you can call to unregister the
  1247. * callbacks.
  1248. */
  1249. on(type: _TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, completed?: CompleteFn | null): Unsubscribe_2 | Subscribe_2<UploadTaskSnapshot>;
  1250. /**
  1251. * This object behaves like a Promise, and resolves with its snapshot data
  1252. * when the upload completes.
  1253. * @param onFulfilled - The fulfillment callback. Promise chaining works as normal.
  1254. * @param onRejected - The rejection callback.
  1255. */
  1256. then<U>(onFulfilled?: ((value: UploadTaskSnapshot) => U | Promise<U>) | null, onRejected?: ((error: StorageError) => U | Promise<U>) | null): Promise<U>;
  1257. /**
  1258. * Equivalent to calling `then(null, onRejected)`.
  1259. */
  1260. catch<T>(onRejected: (p1: StorageError) => T | Promise<T>): Promise<T>;
  1261. /**
  1262. * Adds the given observer.
  1263. */
  1264. private _addObserver;
  1265. /**
  1266. * Removes the given observer.
  1267. */
  1268. private _removeObserver;
  1269. private _notifyObservers;
  1270. private _finishPromise;
  1271. private _notifyObserver;
  1272. /**
  1273. * Resumes a paused task. Has no effect on a currently running or failed task.
  1274. * @returns True if the operation took effect, false if ignored.
  1275. */
  1276. resume(): boolean;
  1277. /**
  1278. * Pauses a currently running task. Has no effect on a paused or failed task.
  1279. * @returns True if the operation took effect, false if ignored.
  1280. */
  1281. pause(): boolean;
  1282. /**
  1283. * Cancels a currently running or paused task. Has no effect on a complete or
  1284. * failed task.
  1285. * @returns True if the operation took effect, false if ignored.
  1286. */
  1287. cancel(): boolean;
  1288. }
  1289. /**
  1290. * Holds data about the current state of the upload task.
  1291. * @public
  1292. */
  1293. export declare interface UploadTaskSnapshot {
  1294. /**
  1295. * The number of bytes that have been successfully uploaded so far.
  1296. */
  1297. bytesTransferred: number;
  1298. /**
  1299. * Before the upload completes, contains the metadata sent to the server.
  1300. * After the upload completes, contains the metadata sent back from the server.
  1301. */
  1302. metadata: FullMetadata;
  1303. /**
  1304. * The reference that spawned this snapshot's upload task.
  1305. */
  1306. ref: StorageReference;
  1307. /**
  1308. * The current state of the task.
  1309. */
  1310. state: TaskState;
  1311. /**
  1312. * The task of which this is a snapshot.
  1313. */
  1314. task: UploadTask;
  1315. /**
  1316. * The total number of bytes to be uploaded.
  1317. */
  1318. totalBytes: number;
  1319. }
  1320. /**
  1321. * Type for url params stored in RequestInfo.
  1322. */
  1323. declare interface UrlParams {
  1324. [name: string]: string | number;
  1325. }
  1326. export { }