• Upload data to the specified S3 object path. By default uses single PUT operation to upload if the payload is less than 5MB. Otherwise, uses multipart upload to upload the payload. If the payload length cannot be determined, uses multipart upload.

    Limitations:

    • Maximum object size is 5TB.
    • Maximum object size if the size cannot be determined before upload is 50GB.

    Parameters

    Returns UploadDataWithPathOutput

    A cancelable and resumable task exposing result promise from result property.

    Throws

    Service: S3Exception thrown when checking for existence of the object.

    Throws

    Validation: StorageValidationErrorCode thrown when a validation error occurs.

    Example

    // Upload a file to s3 bucket
    await uploadData({ path, data: file, options: {
    onProgress, // Optional progress callback.
    } }).result;

    Example

    // Cancel a task
    const uploadTask = uploadData({ path, data: file });
    //...
    uploadTask.cancel();
    try {
    await uploadTask.result;
    } catch (error) {
    if(isCancelError(error)) {
    // Handle error thrown by task cancelation.
    }
    }

    Example

    // Pause and resume a task
    const uploadTask = uploadData({ path, data: file });
    //...
    uploadTask.pause();
    //...
    uploadTask.resume();
    //...
    await uploadTask.result;
  • Upload data to the specified S3 object key. By default uses single PUT operation to upload if the payload is less than 5MB. Otherwise, uses multipart upload to upload the payload. If the payload length cannot be determined, uses multipart upload.

    Limitations:

    • Maximum object size is 5TB.
    • Maximum object size if the size cannot be determined before upload is 50GB.

    Parameters

    Returns UploadDataOutput

    A cancelable and resumable task exposing result promise from the result property.

    Deprecated

    The key and accessLevel parameters are deprecated and will be removed in next major version. Please use path instead.

    Throws

    Service: S3Exception thrown when checking for existence of the object.

    Throws

    Validation: StorageValidationErrorCode thrown when a validation error occurs.

    Example

    // Upload a file to s3 bucket
    await uploadData({ key, data: file, options: {
    onProgress, // Optional progress callback.
    } }).result;

    Example

    // Cancel a task
    const uploadTask = uploadData({ key, data: file });
    //...
    uploadTask.cancel();
    try {
    await uploadTask.result;
    } catch (error) {
    if(isCancelError(error)) {
    // Handle error thrown by task cancelation.
    }
    }

    Example

    // Pause and resume a task
    const uploadTask = uploadData({ key, data: file });
    //...
    uploadTask.pause();
    //...
    uploadTask.resume();
    //...
    await uploadTask.result;