Esempio n. 1
0
 private void completeUpload(InitiateMultipartUploadResult initResponse, List<PartETag> eTags)
     throws Exception {
   CompleteMultipartUploadRequest completeRequest =
       new CompleteMultipartUploadRequest(
           initResponse.getBucketName(), initResponse.getKey(), initResponse.getUploadId(), eTags);
   s3Client.completeMultipartUpload(completeRequest);
 }
Esempio n. 2
0
  private PartETag uploadChunk(
      ByteBuffer bytes, InitiateMultipartUploadResult initResponse, int index) throws Exception {
    byte[] md5 = S3Utils.md5(bytes);

    UploadPartRequest request = new UploadPartRequest();
    request.setBucketName(initResponse.getBucketName());
    request.setKey(initResponse.getKey());
    request.setUploadId(initResponse.getUploadId());
    request.setPartNumber(index);
    request.setPartSize(bytes.limit());
    request.setMd5Digest(S3Utils.toBase64(md5));
    request.setInputStream(new ByteBufferInputStream(bytes));

    UploadPartResult response = s3Client.uploadPart(request);
    PartETag partETag = response.getPartETag();
    if (!response.getPartETag().getETag().equals(S3Utils.toHex(md5))) {
      throw new Exception("Unable to match MD5 for part " + index);
    }

    return partETag;
  }
Esempio n. 3
0
 private void abortUpload(InitiateMultipartUploadResult initResponse) throws Exception {
   AbortMultipartUploadRequest abortRequest =
       new AbortMultipartUploadRequest(
           initResponse.getBucketName(), initResponse.getKey(), initResponse.getUploadId());
   s3Client.abortMultipartUpload(abortRequest);
 }