AWS TransferManager API for Faster Uploads/Downloads With Wasabi
    • 12 Aug 2024
    • 1 Minute to read
    • PDF

    AWS TransferManager API for Faster Uploads/Downloads With Wasabi

    • PDF

    Article summary

    How do I use AWS TransferManager API for faster uploads/downloads with Wasabi?

    The AWS S3 TransferManager API with AWS SDK for Java has been validated for use with Wasabi. This approach makes working with uploads and downloads of large files from Wasabi very fast, easy and convenient.

    TransferManager provides asynchronous management for uploads and downloads between your application and Wasabi. Note that you can also check on the status of your transfers, add handlers to run code when a transfer completes, cancel transfers, and more.

    Below is the sample Java code we tested with TransferManager API for uploading large files with multi-part uploads to Wasabi and it works successfully:

    package com.amazonaws;
    
    import com.amazonaws.AmazonServiceException;
    import com.amazonaws.SdkClientException;
    import com.amazonaws.auth.profile.ProfileCredentialsProvider;
    import com.amazonaws.regions.Regions;
    import com.amazonaws.services.s3.AmazonS3;
    import com.amazonaws.services.s3.AmazonS3ClientBuilder;
    import com.amazonaws.services.s3.transfer.TransferManager;
    import com.amazonaws.services.s3.transfer.TransferManagerBuilder;
    import com.amazonaws.services.s3.transfer.Upload;
    import com.amazonaws.services.s3.*;
    import com.amazonaws.auth.*;
    
    
    import java.io.File;
    
    public class HighLevelMultipartUpload {
    
    public static void main(String[] args) throws Exception {
     Regions clientRegion = Regions.DEFAULT_REGION;
     final String bucketName = "Bucket-Name";
     final String keyName = "File-Name";
     final String filePath = "/File-Path"; // the file is located in the project folder
     final String accessKey = "Wasabi-Access-Key";
     final String secretAccessKey = "Wasabi-Secret-Key";
     final String END_POINT = "https://s3.wasabisys.com"; //for uploading in us-east-1 bucket
    
    try {
     AWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretAccessKey);
     AmazonS3 s3Client = new AmazonS3Client(awsCredentials);
     s3Client.setEndpoint(END_POINT);
     TransferManager tm = TransferManagerBuilder.standard()
     .withS3Client(s3Client)
     .build();
    
    Upload upload = tm.upload(bucketName, keyName, new File(filePath));
     System.out.println("Object upload started");
    
    upload.waitForCompletion();
     System.out.println("Object upload complete");
     } catch (AmazonServiceException e) {
     e.printStackTrace();
     } catch (SdkClientException e) {
    
    e.printStackTrace();
     }
     }
    }

    As these classes implement the Transfer interface. You can modify your script to handle any of the following topics mentioned below 

    Note that this example discusses the use of Wasabi's us-east-1 storage region. To use other Wasabi storage regions, please use the appropriate Wasabi service URL as described in this article