UNPKG

3.35 kBTypeScriptView Raw
1import { UploadDataInput, UploadDataOutput, UploadDataWithPathInput, UploadDataWithPathOutput } from '../../types';
2/**
3 * Upload data to the specified S3 object path. By default uses single PUT operation to upload if the payload is less than 5MB.
4 * Otherwise, uses multipart upload to upload the payload. If the payload length cannot be determined, 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 * @throws Service: `S3Exception` thrown when checking for existence of the object.
11 * @throws Validation: `StorageValidationErrorCode` thrown when a validation error occurs.
12 *
13 * @param input - A `UploadDataWithPathInput` object.
14 *
15 * @returns A cancelable and resumable task exposing result promise from `result`
16 * property.
17 *
18 * @example
19 * ```ts
20 * // Upload a file to s3 bucket
21 * await uploadData({ path, data: file, options: {
22 * onProgress, // Optional progress callback.
23 * } }).result;
24 * ```
25 *
26 * @example
27 * ```ts
28 * // Cancel a task
29 * const uploadTask = uploadData({ path, data: file });
30 * //...
31 * uploadTask.cancel();
32 * try {
33 * await uploadTask.result;
34 * } catch (error) {
35 * if(isCancelError(error)) {
36 * // Handle error thrown by task cancelation.
37 * }
38 * }
39 *```
40 *
41 * @example
42 * ```ts
43 * // Pause and resume a task
44 * const uploadTask = uploadData({ path, data: file });
45 * //...
46 * uploadTask.pause();
47 * //...
48 * uploadTask.resume();
49 * //...
50 * await uploadTask.result;
51 * ```
52 */
53export declare function uploadData(input: UploadDataWithPathInput): UploadDataWithPathOutput;
54/**
55 * Upload data to the specified S3 object key. By default uses single PUT operation to upload if the payload is less than 5MB.
56 * Otherwise, uses multipart upload to upload the payload. If the payload length cannot be determined, uses multipart upload.
57 *
58 * Limitations:
59 * * Maximum object size is 5TB.
60 * * Maximum object size if the size cannot be determined before upload is 50GB.
61 *
62 * @deprecated The `key` and `accessLevel` parameters are deprecated and will be removed in next major version.
63 * Please use {@link https://docs.amplify.aws/javascript/build-a-backend/storage/upload/#uploaddata | path} instead.
64 *
65 * @throws Service: `S3Exception` thrown when checking for existence of the object.
66 * @throws Validation: `StorageValidationErrorCode` thrown when a validation error occurs.
67 *
68 * @param input - A `UploadDataInput` object.
69 *
70 * @returns A cancelable and resumable task exposing result promise from the `result` property.
71 *
72 * @example
73 * ```ts
74 * // Upload a file to s3 bucket
75 * await uploadData({ key, data: file, options: {
76 * onProgress, // Optional progress callback.
77 * } }).result;
78 * ```
79 *
80 * @example
81 * ```ts
82 * // Cancel a task
83 * const uploadTask = uploadData({ key, data: file });
84 * //...
85 * uploadTask.cancel();
86 * try {
87 * await uploadTask.result;
88 * } catch (error) {
89 * if(isCancelError(error)) {
90 * // Handle error thrown by task cancelation.
91 * }
92 * }
93 *```
94 *
95 * @example
96 * ```ts
97 * // Pause and resume a task
98 * const uploadTask = uploadData({ key, data: file });
99 * //...
100 * uploadTask.pause();
101 * //...
102 * uploadTask.resume();
103 * //...
104 * await uploadTask.result;
105 * ```
106 */
107export declare function uploadData(input: UploadDataInput): UploadDataOutput;