@aws-amplify/storage
Version:
Storage category of aws-amplify
33 lines (32 loc) • 996 B
TypeScript
import { DownloadDataInput, DownloadDataOutput } from '../types';
/**
* Download S3 object data to memory
*
* @param input - The DownloadDataInput object.
* @returns A cancelable task exposing result promise from `result` property.
* @throws service: {@link S3Exception} - thrown when checking for existence of the object
* @throws validation: {@link StorageValidationErrorCode } - Validation errors
*
* @example
* ```ts
* // Download a file from s3 bucket
* const { body, eTag } = await downloadData({ key, data: file, options: {
* onProgress, // Optional progress callback.
* } }).result;
* ```
* @example
* ```ts
* // Cancel a task
* const downloadTask = downloadData({ key, data: file });
* //...
* downloadTask.cancel();
* try {
* await downloadTask.result;
* } catch (error) {
* if(isCancelError(error)) {
* // Handle error thrown by task cancelation.
* }
* }
*```
*/
export declare const downloadData: (input: DownloadDataInput) => DownloadDataOutput;