private PartETag uploadChunk(byte[] buffer, int bytesRead, InitiateMultipartUploadResult initResponse, int index) throws Exception { byte[] md5 = S3Utils.md5(buffer, bytesRead); UploadPartRequest request = new UploadPartRequest(); request.setBucketName(initResponse.getBucketName()); request.setKey(initResponse.getKey()); request.setUploadId(initResponse.getUploadId()); request.setPartNumber(index); request.setPartSize(bytesRead); request.setMd5Digest(S3Utils.toBase64(md5)); request.setInputStream(new ByteArrayInputStream(buffer, 0, bytesRead)); 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; }
private Void uploadPart() throws AmazonClientException, BackupRestoreException { UploadPartRequest req = new UploadPartRequest(); req.setBucketName(dataPart.getBucketName()); req.setKey(dataPart.getS3key()); req.setUploadId(dataPart.getUploadID()); req.setPartNumber(dataPart.getPartNo()); req.setPartSize(dataPart.getPartData().length); req.setMd5Digest(SystemUtils.toBase64(dataPart.getMd5())); req.setInputStream(new ByteArrayInputStream(dataPart.getPartData())); UploadPartResult res = client.uploadPart(req); PartETag partETag = res.getPartETag(); if (!partETag.getETag().equals(SystemUtils.toHex(dataPart.getMd5()))) throw new BackupRestoreException( "Unable to match MD5 for part " + dataPart.getPartNo()); partETags.add(partETag); if (this.partsUploaded != null) this.partsUploaded.incrementAndGet(); return null; }
req.setPartSize(lastPartSize); if (uploadContext.hasFinalPartBeenSeen()) { throw new SdkClientException(
req.setPartSize(lastPartSize);
private void uploadPartAndFlushBuffer() throws IOException { boolean operationSuccessful = false; if (this.uploadId == null) { this.uploadId = initiateMultipartUpload(); } try { if (this.partNumber >= MAX_PART_NUMBER) { throw new IOException("Cannot upload any more data: maximum part number reached"); } final InputStream inputStream = new InternalUploadInputStream(this.buf, this.bytesWritten); final UploadPartRequest request = new UploadPartRequest(); request.setBucketName(this.bucket); request.setKey(this.object); request.setInputStream(inputStream); request.setUploadId(this.uploadId); request.setPartSize(this.bytesWritten); request.setPartNumber(this.partNumber++); final UploadPartResult result = this.s3Client.uploadPart(request); this.partETags.add(result.getPartETag()); this.bytesWritten = 0; operationSuccessful = true; } catch (AmazonServiceException e) { throw new IOException(StringUtils.stringifyException(e)); } finally { if (!operationSuccessful) { abortUpload(); } } }
private void uploadPartAndFlushBuffer() throws IOException { boolean operationSuccessful = false; if (this.uploadId == null) { this.uploadId = initiateMultipartUpload(); } try { if (this.partNumber >= MAX_PART_NUMBER) { throw new IOException("Cannot upload any more data: maximum part number reached"); } final InputStream inputStream = new InternalUploadInputStream(this.buf, this.bytesWritten); final UploadPartRequest request = new UploadPartRequest(); request.setBucketName(this.bucket); request.setKey(this.object); request.setInputStream(inputStream); request.setUploadId(this.uploadId); request.setPartSize(this.bytesWritten); request.setPartNumber(this.partNumber++); final UploadPartResult result = this.s3Client.uploadPart(request); this.partETags.add(result.getPartETag()); this.bytesWritten = 0; operationSuccessful = true; } catch (AmazonServiceException e) { throw new IOException(StringUtils.stringifyException(e)); } finally { if (!operationSuccessful) { abortUpload(); } } }
req.setPartSize(lastPartSize); if (uploadContext.hasFinalPartBeenSeen()) { throw new SdkClientException(
req.setPartSize(lastPartSize);