Skip to content

Commit 0006320

Browse files
committed
Convert references
1 parent cccbfa1 commit 0006320

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

packages/storage/exp/api.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export function uploadBytes(
7979
data: Blob | Uint8Array | ArrayBuffer,
8080
metadata?: UploadMetadata
8181
): Promise<UploadResult> {
82+
ref = getModularInstance(ref);
8283
return uploadBytesInternal(
8384
ref as Reference,
8485
data,
@@ -102,6 +103,7 @@ export function uploadString(
102103
format?: string,
103104
metadata?: UploadMetadata
104105
): Promise<UploadResult> {
106+
ref = getModularInstance(ref);
105107
return uploadStringInternal(
106108
ref as Reference,
107109
value,
@@ -124,6 +126,7 @@ export function uploadBytesResumable(
124126
data: Blob | Uint8Array | ArrayBuffer,
125127
metadata?: UploadMetadata
126128
): UploadTask {
129+
ref = getModularInstance(ref);
127130
return uploadBytesResumableInternal(
128131
ref as Reference,
129132
data,
@@ -139,6 +142,7 @@ export function uploadBytesResumable(
139142
* @param ref - StorageReference to get metadata from.
140143
*/
141144
export function getMetadata(ref: StorageReference): Promise<FullMetadata> {
145+
ref = getModularInstance(ref);
142146
return getMetadataInternal(ref as Reference) as Promise<FullMetadata>;
143147
}
144148

@@ -155,6 +159,7 @@ export function updateMetadata(
155159
ref: StorageReference,
156160
metadata: SettableMetadata
157161
): Promise<FullMetadata> {
162+
ref = getModularInstance(ref);
158163
return updateMetadataInternal(
159164
ref as Reference,
160165
metadata as Partial<MetadataInternal>
@@ -187,6 +192,7 @@ export function list(
187192
ref: StorageReference,
188193
options?: ListOptions
189194
): Promise<ListResult> {
195+
ref = getModularInstance(ref);
190196
return listInternal(ref as Reference, options);
191197
}
192198

@@ -210,6 +216,7 @@ export function list(
210216
* folder. `nextPageToken` is never returned.
211217
*/
212218
export function listAll(ref: StorageReference): Promise<ListResult> {
219+
ref = getModularInstance(ref);
213220
return listAllInternal(ref as Reference);
214221
}
215222

@@ -220,6 +227,7 @@ export function listAll(ref: StorageReference): Promise<ListResult> {
220227
* URL for this object.
221228
*/
222229
export function getDownloadURL(ref: StorageReference): Promise<string> {
230+
ref = getModularInstance(ref);
223231
return getDownloadURLInternal(ref as Reference);
224232
}
225233

@@ -230,6 +238,7 @@ export function getDownloadURL(ref: StorageReference): Promise<string> {
230238
* @returns A promise that resolves if the deletion succeeds.
231239
*/
232240
export function deleteObject(ref: StorageReference): Promise<void> {
241+
ref = getModularInstance(ref);
233242
return deleteObjectInternal(ref as Reference);
234243
}
235244

@@ -256,14 +265,11 @@ export function ref(
256265
serviceOrRef: StorageService | StorageReference,
257266
pathOrUrl?: string
258267
): StorageReference | null {
259-
if (serviceOrRef instanceof Reference) {
260-
return refInternal(serviceOrRef as Reference, pathOrUrl);
261-
} else {
262-
return refInternal(
263-
getModularInstance(serviceOrRef) as StorageServiceInternal,
264-
pathOrUrl
265-
);
266-
}
268+
serviceOrRef = getModularInstance(serviceOrRef);
269+
return refInternal(
270+
serviceOrRef as StorageServiceInternal | Reference,
271+
pathOrUrl
272+
);
267273
}
268274

269275
/**
@@ -287,9 +293,9 @@ export function getStorage(
287293
app: FirebaseApp,
288294
bucketUrl?: string
289295
): StorageService {
290-
// Dependencies
296+
app = getModularInstance(app);
291297
const storageProvider: Provider<'storage-exp'> = _getProvider(
292-
getModularInstance(app),
298+
app,
293299
STORAGE_TYPE
294300
);
295301
const storageInstance = storageProvider.getImmediate({

0 commit comments

Comments
 (0)