Skip to content

Commit 3aa8b21

Browse files
Cleanup
1 parent 850a6a5 commit 3aa8b21

File tree

3 files changed

+28
-58
lines changed

3 files changed

+28
-58
lines changed

common/api-review/storage.api.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,15 @@ export class _FirebaseStorageImpl implements FirebaseStorage {
7777
_getAuthToken(): Promise<string | null>;
7878
get host(): string;
7979
set host(host: string);
80+
// Warning: (ae-forgotten-export) The symbol "ConnectionType" needs to be exported by the entry point index.d.ts
8081
// Warning: (ae-forgotten-export) The symbol "RequestInfo" needs to be exported by the entry point index.d.ts
8182
// Warning: (ae-forgotten-export) The symbol "Connection" needs to be exported by the entry point index.d.ts
8283
// Warning: (ae-forgotten-export) The symbol "Request" needs to be exported by the entry point index.d.ts
8384
//
8485
// (undocumented)
85-
_makeRequest<I, O>(requestInfo: RequestInfo_2<I, O>, requestFactory: () => Connection<I>, authToken: string | null, appCheckToken: string | null): Request_2<O>;
86+
_makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo_2<I, O>, requestFactory: () => Connection<I>, authToken: string | null, appCheckToken: string | null): Request_2<O>;
8687
// (undocumented)
87-
makeRequestWithTokens<I, O>(requestInfo: RequestInfo_2<I, O>, requestFactory: () => Connection<I>): Promise<O>;
88+
makeRequestWithTokens<I extends ConnectionType, O>(requestInfo: RequestInfo_2<I, O>, requestFactory: () => Connection<I>): Promise<O>;
8889
_makeStorageReference(loc: _Location): _Reference;
8990
get maxOperationRetryTime(): number;
9091
set maxOperationRetryTime(time: number);

packages/storage/src/implementation/requests.ts

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -207,36 +207,11 @@ export function list(
207207
return requestInfo;
208208
}
209209

210-
export function getBytes(
210+
export function getBytes<I extends ConnectionType>(
211211
service: FirebaseStorageImpl,
212212
location: Location,
213213
maxDownloadSizeBytes?: number
214-
): RequestInfo<ArrayBuffer, ArrayBuffer> {
215-
return createDownloadRequest(location, service, maxDownloadSizeBytes);
216-
}
217-
218-
export function getBlob(
219-
service: FirebaseStorageImpl,
220-
location: Location,
221-
maxDownloadSizeBytes?: number
222-
): RequestInfo<Blob, Blob> {
223-
return createDownloadRequest(location, service, maxDownloadSizeBytes);
224-
}
225-
226-
export function getStream(
227-
service: FirebaseStorageImpl,
228-
location: Location,
229-
maxDownloadSizeBytes?: number
230-
): RequestInfo<NodeJS.ReadableStream, NodeJS.ReadableStream> {
231-
return createDownloadRequest(location, service, maxDownloadSizeBytes);
232-
}
233-
234-
/** Creates a new request to download an object. */
235-
function createDownloadRequest<I extends ConnectionType>(
236-
location: Location,
237-
service: FirebaseStorageImpl,
238-
maxDownloadSizeBytes?: number
239-
): RequestInfo<I, I> {
214+
): RequestInfo<I, I> {
240215
const urlPart = location.fullServerUrl();
241216
const url = makeUrl(urlPart, service.host, service._protocol) + '?alt=media';
242217
const method = 'GET';

packages/storage/src/reference.ts

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,34 @@
1919
* @fileoverview Defines the Firebase StorageReference class.
2020
*/
2121

22-
import { Transform, TransformOptions, PassThrough } from 'stream';
22+
import {PassThrough, Transform, TransformOptions} from 'stream';
2323

24-
import { FbsBlob } from './implementation/blob';
25-
import { Location } from './implementation/location';
26-
import { getMappings } from './implementation/metadata';
27-
import { child, parent, lastComponent } from './implementation/path';
24+
import {FbsBlob} from './implementation/blob';
25+
import {Location} from './implementation/location';
26+
import {getMappings} from './implementation/metadata';
27+
import {child, lastComponent, parent} from './implementation/path';
2828
import {
29-
list as requestsList,
30-
getMetadata as requestsGetMetadata,
31-
updateMetadata as requestsUpdateMetadata,
32-
getDownloadUrl as requestsGetDownloadUrl,
3329
deleteObject as requestsDeleteObject,
34-
multipartUpload,
3530
getBytes,
36-
getBlob,
37-
getStream
31+
getDownloadUrl as requestsGetDownloadUrl,
32+
getMetadata as requestsGetMetadata,
33+
list as requestsList,
34+
multipartUpload,
35+
updateMetadata as requestsUpdateMetadata
3836
} from './implementation/requests';
39-
import { ListOptions, UploadResult } from './public-types';
40-
import { StringFormat, dataFromString } from './implementation/string';
41-
import { Metadata } from './metadata';
42-
import { FirebaseStorageImpl } from './service';
43-
import { ListResult } from './list';
44-
import { UploadTask } from './task';
45-
import { invalidRootOperation, noDownloadURL } from './implementation/error';
46-
import { validateNumber } from './implementation/type';
37+
import {ListOptions, UploadResult} from './public-types';
38+
import {dataFromString, StringFormat} from './implementation/string';
39+
import {Metadata} from './metadata';
40+
import {FirebaseStorageImpl} from './service';
41+
import {ListResult} from './list';
42+
import {UploadTask} from './task';
43+
import {invalidRootOperation, noDownloadURL} from './implementation/error';
44+
import {validateNumber} from './implementation/type';
4745
import {
48-
newBytesConnection,
49-
newTextConnection,
5046
newBlobConnection,
51-
newStreamConnection
47+
newBytesConnection,
48+
newStreamConnection,
49+
newTextConnection
5250
} from './platform/connection';
5351

5452
/**
@@ -186,7 +184,7 @@ export function getBlobInternal(
186184
maxDownloadSizeBytes?: number
187185
): Promise<Blob> {
188186
ref._throwIfRoot('getBlob');
189-
const requestInfo = getBlob(ref.storage, ref._location, maxDownloadSizeBytes);
187+
const requestInfo = getBytes(ref.storage, ref._location, maxDownloadSizeBytes);
190188
return ref.storage
191189
.makeRequestWithTokens(requestInfo, newBlobConnection)
192190
.then(blob =>
@@ -203,11 +201,7 @@ export function getStreamInternal(
203201
maxDownloadSizeBytes?: number
204202
): NodeJS.ReadableStream {
205203
ref._throwIfRoot('getStream');
206-
const requestInfo = getStream(
207-
ref.storage,
208-
ref._location,
209-
maxDownloadSizeBytes
210-
);
204+
const requestInfo = getBytes(ref.storage, ref._location, maxDownloadSizeBytes);
211205

212206
/** A transformer that passes through the first n bytes. */
213207
const newMaxSizeTransform: (n: number) => TransformOptions = n => {

0 commit comments

Comments
 (0)