-
Notifications
You must be signed in to change notification settings - Fork 930
Add Node build for Firebase Storage #5468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
00cfe38
Add Node build for Firebase Storage
schmidt-sebastian b83cd47
Update All Tests.run.xml
schmidt-sebastian ba88035
Feedback
schmidt-sebastian bbd4803
Merge branch 'master' into mrschmidt/nodebuild
schmidt-sebastian f5ea975
Update API reports
schmidt-sebastian 3013b33
Suppress lint
schmidt-sebastian 1fa7ce9
Update API reports
schmidt-sebastian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* @license | ||
* Copyright 2021 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"; | ||
|
||
/** | ||
* 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. | ||
* @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to | ||
* retrieve. | ||
* @returns A Promise that resolves with a Blob containing the object's bytes | ||
*/ | ||
function getBlob( | ||
ref: StorageReference, | ||
maxDownloadSizeBytes?: number | ||
): Promise<Blob> { | ||
throw new Error("Not implemented"); | ||
} | ||
|
||
/** | ||
* Downloads the data at the object's location. Raises an error event if the | ||
* object is not found. | ||
* | ||
* This API is only available in Node. | ||
* | ||
* @public | ||
* @param ref - StorageReference where data should be download. | ||
* @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to | ||
* retrieve. | ||
* @returns A stream with the object's data as bytes | ||
*/ | ||
export function getStream( | ||
ref: StorageReference, | ||
maxDownloadSizeBytes?: number | ||
): NodeJS.ReadableStream { | ||
throw new Error("getStream() is only supported by NodeJS builds"); | ||
} | ||
|
||
// TODO(getbytes): Export getBlob/getStream | ||
|
||
export {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* @license | ||
* Copyright 2021 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"; | ||
|
||
/** | ||
* 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. | ||
* @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to | ||
* retrieve. | ||
* @returns A Promise that resolves with a Blob containing the object's bytes | ||
*/ | ||
function getBlob( | ||
ref: StorageReference, | ||
maxDownloadSizeBytes?: number | ||
): Promise<Blob> { | ||
throw new Error("getBlob() is only available in Browser-like environments"); | ||
} | ||
|
||
/** | ||
* Downloads the data at the object's location. Raises an error event if the | ||
* object is not found. | ||
* | ||
* This API is only available in Node. | ||
* | ||
* @public | ||
* @param ref - StorageReference where data should be download. | ||
* @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to | ||
* retrieve. | ||
* @returns A stream with the object's data as bytes | ||
*/ | ||
export function getStream( | ||
ref: StorageReference, | ||
maxDownloadSizeBytes?: number | ||
): NodeJS.ReadableStream { | ||
throw new Error("Not implemented"); | ||
} | ||
|
||
// TODO(getbytes): Export getBlob/getStream | ||
|
||
export {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* Cloud Storage for Firebase | ||
* | ||
* @packageDocumentation | ||
*/ | ||
|
||
/** | ||
* @license | ||
* Copyright 2021 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. | ||
*/ | ||
|
||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { | ||
_registerComponent, | ||
registerVersion, | ||
SDK_VERSION | ||
} from '@firebase/app'; | ||
|
||
import { FirebaseStorageImpl } from './service'; | ||
import { | ||
Component, | ||
ComponentType, | ||
ComponentContainer, | ||
InstanceFactoryOptions | ||
} from '@firebase/component'; | ||
|
||
import { name, version } from '../package.json'; | ||
|
||
import { FirebaseStorage } from './public-types'; | ||
import { STORAGE_TYPE } from './constants'; | ||
import { ConnectionPool } from './implementation/connectionPool'; | ||
|
||
export * from './api'; | ||
export * from './api.node'; | ||
|
||
function factory( | ||
container: ComponentContainer, | ||
{ instanceIdentifier: url }: InstanceFactoryOptions | ||
): FirebaseStorage { | ||
const app = container.getProvider('app').getImmediate(); | ||
const authProvider = container.getProvider('auth-internal'); | ||
const appCheckProvider = container.getProvider('app-check-internal'); | ||
|
||
return new FirebaseStorageImpl( | ||
app, | ||
authProvider, | ||
appCheckProvider, | ||
new ConnectionPool(), | ||
url, | ||
SDK_VERSION | ||
); | ||
} | ||
|
||
function registerStorage(): void { | ||
_registerComponent( | ||
new Component( | ||
STORAGE_TYPE, | ||
factory, | ||
ComponentType.PUBLIC | ||
).setMultipleInstances(true) | ||
); | ||
|
||
registerVersion(name, version); | ||
} | ||
|
||
registerStorage(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be exported here and in
api.node.ts
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would immediately add it to the public API. Let me suppress the warning for now.