1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | import { FirebaseApp } from '@firebase/app-types';
|
19 | import { CompleteFn, FirebaseError, NextFn, Unsubscribe } from '@firebase/util';
|
20 |
|
21 | export interface FullMetadata extends UploadMetadata {
|
22 | bucket: string;
|
23 | fullPath: string;
|
24 | generation: string;
|
25 | metageneration: string;
|
26 | name: string;
|
27 | size: number;
|
28 | timeCreated: string;
|
29 | updated: string;
|
30 | }
|
31 |
|
32 | export interface Reference {
|
33 | bucket: string;
|
34 | child(path: string): Reference;
|
35 | delete(): Promise<void>;
|
36 | fullPath: string;
|
37 | getDownloadURL(): Promise<string>;
|
38 | getMetadata(): Promise<FullMetadata>;
|
39 | name: string;
|
40 | parent: Reference | null;
|
41 | put(
|
42 | data: Blob | Uint8Array | ArrayBuffer,
|
43 | metadata?: UploadMetadata
|
44 | ): UploadTask;
|
45 | putString(
|
46 | data: string,
|
47 | format?: StringFormat,
|
48 | metadata?: UploadMetadata
|
49 | ): UploadTask;
|
50 | root: Reference;
|
51 | storage: FirebaseStorage;
|
52 | toString(): string;
|
53 | updateMetadata(metadata: SettableMetadata): Promise<FullMetadata>;
|
54 | listAll(): Promise<ListResult>;
|
55 | list(options?: ListOptions): Promise<ListResult>;
|
56 | }
|
57 |
|
58 | export interface ListResult {
|
59 | prefixes: Reference[];
|
60 | items: Reference[];
|
61 | nextPageToken: string | null;
|
62 | }
|
63 |
|
64 | export interface ListOptions {
|
65 | maxResults?: number | null;
|
66 | pageToken?: string | null;
|
67 | }
|
68 |
|
69 | export interface SettableMetadata {
|
70 | cacheControl?: string | null;
|
71 | contentDisposition?: string | null;
|
72 | contentEncoding?: string | null;
|
73 | contentLanguage?: string | null;
|
74 | contentType?: string | null;
|
75 | customMetadata?: {
|
76 | [ key: string]: string;
|
77 | } | null;
|
78 | }
|
79 |
|
80 | export type StringFormat = string;
|
81 | export type TaskEvent = string;
|
82 | export type TaskState = string;
|
83 |
|
84 | export interface UploadMetadata extends SettableMetadata {
|
85 | md5Hash?: string | null;
|
86 | }
|
87 |
|
88 | interface FirebaseStorageError extends FirebaseError {
|
89 | serverResponse: string | null;
|
90 | }
|
91 |
|
92 | export interface StorageObserver<T> {
|
93 | next?: NextFn<T> | null;
|
94 | error?: (error: FirebaseStorageError) => void | null;
|
95 | complete?: CompleteFn | null;
|
96 | }
|
97 |
|
98 | export interface UploadTask {
|
99 | cancel(): boolean;
|
100 | catch(onRejected: (error: FirebaseStorageError) => any): Promise<any>;
|
101 | on(
|
102 | event: TaskEvent,
|
103 | nextOrObserver?:
|
104 | | StorageObserver<UploadTaskSnapshot>
|
105 | | null
|
106 | | ((snapshot: UploadTaskSnapshot) => any),
|
107 | error?: ((a: FirebaseStorageError) => any) | null,
|
108 | complete?: Unsubscribe | null
|
109 | ): Function;
|
110 | pause(): boolean;
|
111 | resume(): boolean;
|
112 | snapshot: UploadTaskSnapshot;
|
113 | then(
|
114 | onFulfilled?: ((snapshot: UploadTaskSnapshot) => any) | null,
|
115 | onRejected?: ((error: FirebaseStorageError) => any) | null
|
116 | ): Promise<any>;
|
117 | }
|
118 |
|
119 | export interface UploadTaskSnapshot {
|
120 | bytesTransferred: number;
|
121 | metadata: FullMetadata;
|
122 | ref: Reference;
|
123 | state: TaskState;
|
124 | task: UploadTask;
|
125 | totalBytes: number;
|
126 | }
|
127 |
|
128 | export class FirebaseStorage {
|
129 | private constructor();
|
130 |
|
131 | app: FirebaseApp;
|
132 | maxOperationRetryTime: number;
|
133 | maxUploadRetryTime: number;
|
134 | ref(path?: string): Reference;
|
135 | refFromURL(url: string): Reference;
|
136 | setMaxOperationRetryTime(time: number): void;
|
137 | setMaxUploadRetryTime(time: number): void;
|
138 | useEmulator(host: string, port: number): void;
|
139 | }
|
140 |
|
141 | declare module '@firebase/component' {
|
142 | interface NameServiceMapping {
|
143 | 'storage': FirebaseStorage;
|
144 | }
|
145 | }
|
146 |
|
\ | No newline at end of file |