List of usage examples for com.amazonaws.services.s3.model UploadPartRequest setLastPart
public void setLastPart(boolean isLastPart)
From source file:alluxio.underfs.s3a.S3ALowLevelOutputStream.java
License:Apache License
@Override public void close() throws IOException { if (mClosed) { return;//www .j a va 2s. co m } // Set the closed flag, we never retry close() even if exception occurs mClosed = true; // Multi-part upload has not been initialized if (mUploadId == null) { LOG.debug("S3A Streaming upload output stream closed without uploading any data."); return; } try { if (mFile != null) { mLocalOutputStream.close(); int partNumber = mPartNumber.getAndIncrement(); final UploadPartRequest uploadRequest = new UploadPartRequest().withBucketName(mBucketName) .withKey(mKey).withUploadId(mUploadId).withPartNumber(partNumber).withFile(mFile) .withPartSize(mFile.length()); uploadRequest.setLastPart(true); execUpload(uploadRequest); } waitForAllPartsUpload(); completeMultiPartUpload(); } catch (Exception e) { LOG.error("Failed to upload {}: {}", mKey, e.toString()); throw new IOException(e); } }
From source file:com.upplication.s3fs.S3OutputStream.java
License:Open Source License
private void uploadPart(final InputStream content, final long contentLength, final byte[] checksum, final int partNumber, final boolean lastPart) throws IOException { if (aborted)//from w w w . j av a2 s . co m return; final UploadPartRequest request = new UploadPartRequest(); request.setBucketName(objectId.getBucket()); request.setKey(objectId.getKey()); request.setUploadId(uploadId); request.setPartNumber(partNumber); request.setPartSize(contentLength); request.setInputStream(content); request.setLastPart(lastPart); request.setMd5Digest(Base64.encodeAsString(checksum)); final PartETag partETag = s3.uploadPart(request).getPartETag(); log.trace("Uploaded part {} with length {} for {}: {}", partETag.getPartNumber(), contentLength, objectId, partETag.getETag()); partETags.add(partETag); }