Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian committed Sep 3, 2021
1 parent fe531e9 commit ad2374e
Show file tree
Hide file tree
Showing 29 changed files with 774 additions and 481 deletions.
17 changes: 10 additions & 7 deletions common/api-review/storage.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class _FirebaseStorageImpl implements FirebaseStorage {
constructor(
app: FirebaseApp, _authProvider: Provider<FirebaseAuthInternalName>,
_appCheckProvider: Provider<AppCheckInternalComponentName>,
_pool: ConnectionPool, _url?: string | undefined, _firebaseVersion?: string | undefined);
_url?: string | undefined, _firebaseVersion?: string | undefined);
readonly app: FirebaseApp;
// (undocumented)
readonly _appCheckProvider: Provider<AppCheckInternalComponentName>;
Expand All @@ -79,23 +79,20 @@ export class _FirebaseStorageImpl implements FirebaseStorage {
get host(): string;
set host(host: string);
// Warning: (ae-forgotten-export) The symbol "RequestInfo" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "Connection" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "Request" needs to be exported by the entry point index.d.ts
//
// (undocumented)
_makeRequest<T>(requestInfo: RequestInfo_2<T>, authToken: string | null, appCheckToken: string | null): Request_2<T>;
_makeRequest<I, O>(requestInfo: RequestInfo_2<I, O>, requestFactory: () => Connection<I>, authToken: string | null, appCheckToken: string | null): Request_2<O>;
// (undocumented)
makeRequestWithTokens<T>(requestInfo: RequestInfo_2<T>): Promise<Request_2<T>>;
makeRequestWithTokens<I, O>(requestInfo: RequestInfo_2<I, O>, requestFactory: () => Connection<I>): Promise<Request_2<O>>;
_makeStorageReference(loc: _Location): _Reference;
get maxOperationRetryTime(): number;
set maxOperationRetryTime(time: number);
get maxUploadRetryTime(): number;
set maxUploadRetryTime(time: number);
// (undocumented)
_overrideAuthToken?: string;
// Warning: (ae-forgotten-export) The symbol "ConnectionPool" needs to be exported by the entry point index.d.ts
//
// (undocumented)
readonly _pool: ConnectionPool;
// (undocumented)
readonly _url?: string | undefined;
}
Expand All @@ -114,6 +111,12 @@ export interface FullMetadata extends UploadMetadata {
updated: string;
}

// @public
export function getBlob(ref: StorageReference): Promise<Blob>;

// @public
export function getBytes(ref: StorageReference): Promise<ArrayBuffer>;

// @internal (undocumented)
export function _getChild(ref: StorageReference, childPath: string): _Reference;

Expand Down
2 changes: 1 addition & 1 deletion packages/storage/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = function (config) {

function getTestFiles(argv) {
let unitTestFiles = ['test/unit/*'];
let integrationTestFiles = ['test/integration/*'];
let integrationTestFiles = ['test/integration/*', 'test/browser/*'];

if (argv.unit) {
return unitTestFiles;
Expand Down
2 changes: 1 addition & 1 deletion packages/storage/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const es2017Plugins = [
const es2017Builds = [
// Node
{
input: './src/index.ts',
input: './src/index.node.ts',
output: {
file: pkg.main,
format: 'cjs',
Expand Down
39 changes: 39 additions & 0 deletions packages/storage/src/api.browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { StorageReference } from './public-types';
import { Reference, getBlobInternal } from '../src/reference';
import { getModularInstance } from '@firebase/util';

/**
* Downloads the data at the object's location. Returns an error if the object
* is not found.
*
* To use this functionality, you have to whitelist your app's origin in your
* Cloud Storage bucket. See also
* https://cloud.google.com/storage/docs/configuring-cors
*
* This API is not available in Node.
*
* @public
* @param ref - StorageReference where data should be download.
* @returns A Promise that resolves with a Blob containing the object's bytes
*/
export function getBlob(ref: StorageReference): Promise<Blob> {
ref = getModularInstance(ref);
return getBlobInternal(ref as Reference);
}
20 changes: 19 additions & 1 deletion packages/storage/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ import {
getDownloadURL as getDownloadURLInternal,
deleteObject as deleteObjectInternal,
Reference,
_getChild as _getChildInternal
_getChild as _getChildInternal,
getBytesInternal
} from './reference';
import { STORAGE_TYPE } from './constants';
import { EmulatorMockTokenOptions, getModularInstance } from '@firebase/util';
Expand All @@ -74,6 +75,23 @@ export {
TaskState as _TaskState
} from './implementation/taskenums';

/**
* Downloads the data at the object's location. Returns an error if the object
* is not found.
*
* To use this functionality, you have to whitelist your app's origin in your
* Cloud Storage bucket. See also
* https://cloud.google.com/storage/docs/configuring-cors
*
* @public
* @param ref - StorageReference where data should be download.
* @returns A Promise containing the object's bytes
*/
export function getBytes(ref: StorageReference): Promise<ArrayBuffer> {
ref = getModularInstance(ref);
return getBytesInternal(ref as Reference);
}

/**
* Uploads data to this object's location.
* The upload is not resumable.
Expand Down
16 changes: 9 additions & 7 deletions packages/storage/src/implementation/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
* limitations under the License.
*/

/**
* Network headers
*/
export interface Headers {
[name: string]: string;
}
/** Network headers */
export type Headers = Record<string, string>;

/**
* A lightweight wrapper around XMLHttpRequest with a
* goog.net.XhrIo-like interface.
*
* ResponseType is generally either `string` or `ArrayBuffer`. You can create
* a new connection by invoking `newTextConnection()` or
* `newBytesConnection()`.
*/
export interface Connection {
export interface Connection<ResponseType> {
send(
url: string,
method: string,
Expand All @@ -38,6 +38,8 @@ export interface Connection {

getStatus(): number;

getResponse(): ResponseType;

getResponseText(): string;

/**
Expand Down
31 changes: 0 additions & 31 deletions packages/storage/src/implementation/connectionPool.ts

This file was deleted.

Loading

0 comments on commit ad2374e

Please sign in to comment.