|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright 2021 Google LLC |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +import {StorageReference} from "./public-types"; |
| 19 | + |
| 20 | +/** |
| 21 | + * Downloads the data at the object's location. Returns an error if the object |
| 22 | + * is not found. |
| 23 | + * |
| 24 | + * To use this functionality, you have to whitelist your app's origin in your |
| 25 | + * Cloud Storage bucket. See also |
| 26 | + * https://cloud.google.com/storage/docs/configuring-cors |
| 27 | + * |
| 28 | + * This API is not available in Node. |
| 29 | + * |
| 30 | + * @public |
| 31 | + * @param ref - StorageReference where data should be download. |
| 32 | + * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to |
| 33 | + * retrieve. |
| 34 | + * @returns A Promise that resolves with a Blob containing the object's bytes |
| 35 | + */ |
| 36 | +// eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 37 | +function getBlob( |
| 38 | + ref: StorageReference, |
| 39 | + maxDownloadSizeBytes?: number |
| 40 | +): Promise<Blob> { |
| 41 | + throw new Error("getBlob() is only available in Browser-like environments"); |
| 42 | +} |
| 43 | + |
| 44 | +/** |
| 45 | + * Downloads the data at the object's location. Raises an error event if the |
| 46 | + * object is not found. |
| 47 | + * |
| 48 | + * This API is only available in Node. |
| 49 | + * |
| 50 | + * @public |
| 51 | + * @param ref - StorageReference where data should be download. |
| 52 | + * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to |
| 53 | + * retrieve. |
| 54 | + * @returns A stream with the object's data as bytes |
| 55 | + */ |
| 56 | +// eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 57 | +function getStream( |
| 58 | + ref: StorageReference, |
| 59 | + maxDownloadSizeBytes?: number |
| 60 | +): NodeJS.ReadableStream { |
| 61 | + throw new Error("Not implemented"); |
| 62 | +} |
| 63 | + |
| 64 | +// TODO(getbytes): Export getBlob/getStream |
| 65 | + |
| 66 | +export {}; |
0 commit comments