-
Notifications
You must be signed in to change notification settings - Fork 938
Add getBytes() #5672
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
Add getBytes() #5672
Changes from 27 commits
62eadc3
bbe754a
241e1ff
9ad21e0
d377aa7
1d7ba87
9d42583
b300fe9
718c537
9838a74
bbfba22
e4d2cc9
3396393
8fef258
ce4b617
c8bc1ac
32e8978
f5f71e5
fce32fe
b0a2c6c
8fb010b
850a6a5
7637d20
7955731
3aa8b21
98ca7f0
15b1413
d119bfb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@firebase/storage": minor | ||
"firebase": minor | ||
--- | ||
|
||
Adds `getBytes()`, `getStream()` and `getBlob()`, which allow direct file downloads from the SDK. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
|
@@ -76,6 +77,28 @@ export { | |
} from './implementation/taskenums'; | ||
export { StringFormat }; | ||
|
||
/** | ||
* 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @egilmorez can you please scan the PR and review the comments with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was hoping @markarndt could give that a go . . . but if he's too busy and there's urgency, I can take a look this afternoon for sure. |
||
* @param ref - StorageReference where data should be download. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "..should be downloaded." |
||
* @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to | ||
* retrieve. | ||
* @returns A Promise containing the object's bytes | ||
*/ | ||
export function getBytes( | ||
ref: StorageReference, | ||
maxDownloadSizeBytes?: number | ||
): Promise<ArrayBuffer> { | ||
ref = getModularInstance(ref); | ||
return getBytesInternal(ref as Reference, maxDownloadSizeBytes); | ||
} | ||
|
||
/** | ||
* Uploads data to this object's location. | ||
* The upload is not resumable. | ||
|
Uh oh!
There was an error while loading. Please reload this page.