UNPKG

996 BTypeScriptView Raw
1import { DownloadDataInput, DownloadDataOutput } from '../types';
2/**
3 * Download S3 object data to memory
4 *
5 * @param input - The DownloadDataInput object.
6 * @returns A cancelable task exposing result promise from `result` property.
7 * @throws service: {@link S3Exception} - thrown when checking for existence of the object
8 * @throws validation: {@link StorageValidationErrorCode } - Validation errors
9 *
10 * @example
11 * ```ts
12 * // Download a file from s3 bucket
13 * const { body, eTag } = await downloadData({ key, data: file, options: {
14 * onProgress, // Optional progress callback.
15 * } }).result;
16 * ```
17 * @example
18 * ```ts
19 * // Cancel a task
20 * const downloadTask = downloadData({ key, data: file });
21 * //...
22 * downloadTask.cancel();
23 * try {
24 * await downloadTask.result;
25 * } catch (error) {
26 * if(isCancelError(error)) {
27 * // Handle error thrown by task cancelation.
28 * }
29 * }
30 *```
31 */
32export declare const downloadData: (input: DownloadDataInput) => DownloadDataOutput;