File is not completely downloaded using Amazon S3 Transfer Manager AWS SDK Java 2

0

I'm facing a strange issue with the API I am trying to build, specifically when trying to download a file. Here's what's happening:

When I run the API on my local machine and request to download a file, everything works fine and the whole file gets downloaded without any problems. However, when I try to make the same request on staging where the API is deployed, only a small part of the file is downloaded.

The Amazon S3 async client is set up the same way for both my local environment and the staging environment, except for the credentials provider object. we use the S3 Transfer Manager to handle file downloads

here is the code to download a file

public Long downloadFile(
      String key, String downloadedFileWithPath) {
    if (key == null || key.isEmpty() || downloadedFileWithPath == null
      || downloadedFileWithPath.isEmpty()) {
      throw new IllegalArgumentException(
        "key and downloadedFileWithPath should have a value.");
    }
    DownloadFileRequest downloadFileRequest =
        DownloadFileRequest.builder()
            .getObjectRequest(b -> b.bucket(bucketName).key(key))
            .addTransferListener(LoggingTransferListener.create())
            .destination(Paths.get(downloadedFileWithPath))
            .build();

    FileDownload downloadFile = transferManager.downloadFile(
        downloadFileRequest);

    CompletedFileDownload downloadResult = downloadFile.completionFuture()
        .join();
    return downloadResult.response().contentLength();


  }

질문됨 7달 전455회 조회
1개 답변
0

Hello

As per my understanding, you are facing issues in downloading file using S3 Transfer Manager utility in SDK in your staging environment while the same is working in your local system.

I tried to replicate the same issue in one of my EC2 servers, where I used the code from the section Download a file from an S3 bucket in the document available here.

In my case I was able to download the file from my S3 bucket in both the scenarios -> local system and in one of my EC2 servers. I initialized the object of S3TransferManager with default settings and with custom settings. Both the scenarios worked at my end. You can read more about creating an instance of the S3 Transfer Manager from the document available here.

I request you to please check and provide few things from your end:

  1. Confirm that you are using Java SDK version 2.19.1 or a version higher than this.
  2. Confirm that you are using the latest version of aws-crt artifact dependency. You can check the latest version of aws-crt from the Maven document
  3. With S3 Transfer Manager, we also get the feature of monitoring the transfer's progress in real time. Please check and confirm if the transfer progress was fully completed or interrupted/paused in between. Check if there was any error message thrown.
  4. Please try to configure a S3 Transfer Manager with custom settings as mentioned in the document here

If you have a technical support plan with you, you can also reach out to us by creating a case from Support center and providing all the above-mentioned information as we can then access the resources in your account for better troubleshooting.

Thank You!

AWS
지원 엔지니어
답변함 7달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠