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