bharatviswa504 commented on a change in pull request #1279: HDDS-1942. Support
copy during S3 multipart upload part creation
URL: https://github.com/apache/hadoop/pull/1279#discussion_r314534295
##########
File path:
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java
##########
@@ -553,12 +555,45 @@ private Response createMultipartKey(String bucket,
String key, long length,
OzoneBucket ozoneBucket = getBucket(bucket);
OzoneOutputStream ozoneOutputStream = ozoneBucket.createMultipartKey(
key, length, partNumber, uploadID);
- IOUtils.copy(body, ozoneOutputStream);
+
+ String copyHeader = headers.getHeaderString(COPY_SOURCE_HEADER);
+ if (copyHeader != null) {
+ Pair<String, String> result = parseSourceHeader(copyHeader);
+
+ String sourceBucket = result.getLeft();
+ String sourceKey = result.getRight();
+
+ try (OzoneInputStream sourceObject =
+ getBucket(sourceBucket).readKey(sourceKey)) {
+
+ String range =
+ headers.getHeaderString(COPY_SOURCE_HEADER_RANGE);
+ if (range != null) {
+ RangeHeader rangeHeader =
+ RangeHeaderParserUtil.parseRangeHeader(range, 0);
+ IOUtils.copyLarge(sourceObject, ozoneOutputStream,
+ rangeHeader.getStartOffset(),
+ rangeHeader.getEndOffset() - rangeHeader.getStartOffset());
+
+ } else {
+ IOUtils.copy(sourceObject, ozoneOutputStream);
+ }
+ }
+
+ } else {
+ IOUtils.copy(body, ozoneOutputStream);
+ }
ozoneOutputStream.close();
OmMultipartCommitUploadPartInfo omMultipartCommitUploadPartInfo =
ozoneOutputStream.getCommitUploadPartInfo();
- return Response.status(Status.OK).header("ETag",
- omMultipartCommitUploadPartInfo.getPartName()).build();
+ String eTag = omMultipartCommitUploadPartInfo.getPartName();
+
+ if (copyHeader != null) {
+ return Response.ok(new CopyPartResult(eTag)).build();
Review comment:
CopyPartResult from the documentation has 2 fields etag and LastModified.
Here we are not setting lastModified.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]