Example usage for com.amazonaws.services.s3.model CopyPartRequest getFirstByte

List of usage examples for com.amazonaws.services.s3.model CopyPartRequest getFirstByte

Introduction

In this page you can find the example usage for com.amazonaws.services.s3.model CopyPartRequest getFirstByte.

Prototype

public Long getFirstByte() 

Source Link

Document

Returns the optional start range to copy from the source object.

Usage

From source file:com.upplication.s3fs.AmazonS3Client.java

License:Open Source License

static CopyPartResult copyPart0(AmazonS3 client, CopyPartRequest request, S3MultipartOptions opts)
        throws IOException, InterruptedException {

    final String objectId = request.getUploadId();
    final int partNumber = request.getPartNumber();
    final long len = request.getLastByte() - request.getFirstByte();

    int attempt = 0;
    CopyPartResult result = null;//from  ww w.  j  ava2s.c  o m
    while (result == null) {
        attempt++;
        try {
            log.trace("Copying multipart {} with length {} attempt {} for {} ", partNumber, len, attempt,
                    objectId);
            result = client.copyPart(request);
        } catch (AmazonClientException e) {
            if (attempt >= opts.getMaxAttempts())
                throw new IOException("Failed to upload multipart data to Amazon S3", e);

            log.debug("Failed to upload part {} attempt {} for {} -- Caused by: {}", partNumber, attempt,
                    objectId, e.getMessage());
            Thread.sleep(opts.getRetrySleepWithAttempt(attempt));
        }
    }

    return result;
}