Skip to content

Add ability to set metadata for object uploads in transfer library. - #76

Merged
JonathanHenson merged 1 commit into
aws:masterfrom
kahkeng:master
Feb 4, 2016
Merged

JonathanHenson merged 1 commit into
aws:masterfrom
kahkeng:master

Conversation

@kahkeng

@kahkeng kahkeng commented Jan 11, 2016

Copy link
Copy Markdown
Contributor

Adding the ability for users of TransferClient to set metadata of objects they are uploading. Let me know if there's anything that needs to change with the new public methods I added here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like for the map to be in the function call instead of in this object. This object does not contain any other s3 object specific data; it is a handle for callbacks and status checks etc...

Also, when you do so, be sure to handle r-values instead of just a copy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok that makes sense, thanks for the review. I was wondering if I should go that route but there are many other request properties available in a PutObjectRequest/CreateMultipartUploadRequest that are yet to be implemented here (cache control, content encoding, request payer, etc) and this would be an api breaking change each time unless we did function overloading for UploadFile. Would that be acceptable or we're ok changing the function signature each time to add a new property?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two overloads should work. Leave the original, then add one with the map as
const ref, then another as an r-value.
On Jan 12, 2016 10:43 AM, "kahkeng" [email protected] wrote:

In aws-cpp-sdk-transfer/include/aws/transfer/UploadFileRequest.h
#76 (comment):

@@ -126,6 +126,11 @@ class AWS_TRANSFER_API UploadFileRequest : public S3FileRequest, public std::ena
bool HasPassedGetObject() const { return m_getObjectPassed.load(); }
bool HasPassedListObjects() const { return m_listObjectsPassed.load(); }

  • // A map of metadata to store with the object in S3.

Ok that makes sense, thanks for the review. I was wondering if I should go
that route but there are many other request properties available in a
PutObjectRequest that are yet to be implemented here (cache control,
content encoding, request payer, etc) and this would be an api breaking
change each time unless we did function overloading for UploadFile. Would
that be acceptable or we're ok changing the function signature each time to
add a new property?

—
Reply to this email directly or view it on GitHub
https://github.com/awslabs/aws-sdk-cpp/pull/76/files#r49495151.

@JonathanHenson

Copy link
Copy Markdown
Contributor

nice work on this, see my comment above.

@kahkeng
kahkeng force-pushed the master branch 3 times, most recently from 766c6ed to 23b358b Compare January 13, 2016 20:39
@kahkeng

kahkeng commented Jan 13, 2016

Copy link
Copy Markdown
Contributor Author

Ok I refactored to what I think you were suggesting, let me know if I misunderstood you or if anything needs to change. I understand that we don't want to use the UploadFileRequest object as a container for data. I'm just a little concerned that we will need to have many overloaded methods to transfer the various attributes to the underlying CreateMultipartUploadRequest and PutObjectRequest objects. I'm just doing it for metadata here but there are many more that aren't supported yet.

Thanks!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASSERT_EQ(metadata["key1"], headObjectMetadata["key1"]);

@JonathanHenson

Copy link
Copy Markdown
Contributor

Thanks for your work on this! Just a few thoughts.

@kahkeng
kahkeng force-pushed the master branch 3 times, most recently from ac3baf4 to 50ff929 Compare January 19, 2016 00:43
@kahkeng

kahkeng commented Jan 19, 2016

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback, I think I addressed them all in this new commit. Regarding putting metadata into the initialization list, I had to make one of the new constructors the default constructor, otherwise, I'd get a mem-initializer for 'metadata' follows constructor delegation error. Also, I tried to read up more about rvalues/std::forward, hope I got its use correct here but let me know if it isn't. Thanks!

@JonathanHenson

Copy link
Copy Markdown
Contributor

This looks good. I'm going to pull down and run through the test suite. If everything works correctly, I'll merge the request.

Thanks for your work on this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, to confirm, I think I also need to wrap metadata here with std::forward? If so, I can adjust this patch.

@kahkeng

kahkeng commented Jan 22, 2016

Copy link
Copy Markdown
Contributor Author

I've added one more instance of std::forward in TransferClient when creating the UploadFileRequest object with rvalue metadata, and changed my tests to have cCreateBucket = true so they can run individually, and replaced the old commit with this new one. Hope it's all set now.

@kahkeng

kahkeng commented Jan 28, 2016

Copy link
Copy Markdown
Contributor Author

Updated the diff to use std::move instead of std::forward since I've learnt the former is meant for rvalue references which is the case here, and the latter, although it works here too, seems meant more for universal references. I've also checked via print statements that the rvalue reference constructor of UploadFileRequest gets called when I pass in an rvalue metadata into the TransferClient uploadFile method. Please let me know if it's fine to merge now, thanks!

JonathanHenson added a commit that referenced this pull request Feb 4, 2016
Add ability to set metadata for object uploads in transfer library.
@JonathanHenson
JonathanHenson merged commit 3bc16df into aws:master Feb 4, 2016
krzysztof-trzepla pushed a commit to krzysztof-trzepla/aws-sdk-cpp that referenced this pull request May 21, 2016
…rgs to develop

* commit '4c7d1c51e4676d068823cd5c48460e610003efbd':
  Add new args to docker.py functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants