UNPKG

2.17 kBTypeScriptView Raw
1import { DownloadDataInput, DownloadDataOutput, DownloadDataWithPathInput, DownloadDataWithPathOutput } from '../types';
2/**
3 * Download S3 object data to memory
4 *
5 * @param input - The `DownloadDataWithPathInput` object.
6 * @returns A cancelable task exposing result promise from `result` property.
7 * @throws service: `S3Exception` - thrown when checking for existence of the object
8 * @throws validation: `StorageValidationErrorCode` - Validation errors
9 *
10 * @example
11 * ```ts
12 * // Download a file from s3 bucket
13 * const { body, eTag } = await downloadData({ path, options: {
14 * onProgress, // Optional progress callback.
15 * } }).result;
16 * ```
17 * @example
18 * ```ts
19 * // Cancel a task
20 * const downloadTask = downloadData({ path });
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 function downloadData(input: DownloadDataWithPathInput): DownloadDataWithPathOutput;
33/**
34 * @deprecated The `key` and `accessLevel` parameters are deprecated and may be removed in the next major version.
35 * Please use {@link https://docs.amplify.aws/react/build-a-backend/storage/download/#downloaddata | path} instead.
36 *
37 * Download S3 object data to memory
38 *
39 * @param input - The `DownloadDataInput` object.
40 * @returns A cancelable task exposing result promise from `result` property.
41 * @throws service: `S3Exception` - thrown when checking for existence of the object
42 * @throws validation: `StorageValidationErrorCode` - Validation errors
43 *
44 * @example
45 * ```ts
46 * // Download a file from s3 bucket
47 * const { body, eTag } = await downloadData({ key, options: {
48 * onProgress, // Optional progress callback.
49 * } }).result;
50 * ```
51 * @example
52 * ```ts
53 * // Cancel a task
54 * const downloadTask = downloadData({ key });
55 * //...
56 * downloadTask.cancel();
57 * try {
58 * await downloadTask.result;
59 * } catch (error) {
60 * if(isCancelError(error)) {
61 * // Handle error thrown by task cancelation.
62 * }
63 * }
64 *```
65 */
66export declare function downloadData(input: DownloadDataInput): DownloadDataOutput;