UNPKG

1.52 kBTypeScriptView Raw
1import { UploadDataInput, UploadDataOutput } from '../../types';
2/**
3 * Upload data to specified S3 object. By default, it uses single PUT operation to upload if the data is less than 5MB.
4 * Otherwise, it uses multipart upload to upload the data. If the data length is unknown, it uses multipart upload.
5 *
6 * Limitations:
7 * * Maximum object size is 5TB.
8 * * Maximum object size if the size cannot be determined before upload is 50GB.
9 *
10 * @param input - The UploadDataInput object.
11 * @returns A cancelable and resumable task exposing result promise from `result`
12 * property.
13 * @throws service: {@link S3Exception} - thrown when checking for existence of the object
14 * @throws validation: {@link StorageValidationErrorCode } - Validation errors.
15 *
16 * @example
17 * ```ts
18 * // Upload a file to s3 bucket
19 * await uploadData({ key, data: file, options: {
20 * onProgress, // Optional progress callback.
21 * } }).result;
22 * ```
23 * @example
24 * ```ts
25 * // Cancel a task
26 * const uploadTask = uploadData({ key, data: file });
27 * //...
28 * uploadTask.cancel();
29 * try {
30 * await uploadTask.result;
31 * } catch (error) {
32 * if(isCancelError(error)) {
33 * // Handle error thrown by task cancelation.
34 * }
35 * }
36 *```
37 *
38 * @example
39 * ```ts
40 * // Pause and resume a task
41 * const uploadTask = uploadData({ key, data: file });
42 * //...
43 * uploadTask.pause();
44 * //...
45 * uploadTask.resume();
46 * //...
47 * await uploadTask.result;
48 * ```
49 */
50export declare const uploadData: (input: UploadDataInput) => UploadDataOutput;