0

Hi guys I'm working under a project like Downloading file from amazon s3. My file was successfully downloaded by chunks [i.e download 5 by 5 MB or more]. But my downloaded file was corrupted after the completion.

GetObjectRequest rangeObjectRequest = new getObjectRequest(existingBucketName, fileName);
long filePosition = 0;
int part = 0;
while (filePosition < contentLength) 
{
    blockSize = Math.min(blockSize, (contentLength - filePosition));
    Thread.currentThread();
    if( Thread.interrupted() )
    {
        throw new InterruptedException();
    }
    rangeObjectRequest.setRange(filePosition, filePosition + blockSize); 
    S3Object objectPortion = s3Client.getObject(rangeObjectRequest);
    InputStream objectData = objectPortion.getObjectContent();

    IOUtils.copy(objectData, out);

    filePosition = filePosition + blockSize;

    part++;
}
out.close();
objectContent.close();
  • https://stackoverflow.com/questions/16788437/how-to-download-a-part-of-a-file-from-url-in-android https://stackoverflow.com/questions/11110153/java-reading-file-chunk-by-chunk – Pradeep Oct 31 '17 at 05:56
  • Hello Viji please gothrough above links – Pradeep Oct 31 '17 at 05:56

0 Answers0