S3Mock icon indicating copy to clipboard operation
S3Mock copied to clipboard

S3Mock overwrites file data with ACL XML on 'putObject'

Open lgoldstein opened this issue 6 years ago • 2 comments

First of all - great code - helps a lot with debugging S3 code locally.

While trying to use S3Browser with the mock as a server I encountered a problem with uploading files (which translates to calling the FileStoreController#putObject endpoint). After some debugging I found out the following:

The application invokes putObject twice - once with file contents and once again with an XML that contains ACL data. The code does not distinguish between the 2 calls and thus overwrites the original file data with the ACL XML content.

A quick analysis of the requests shows that there are some differences between the requests in the headers - which do not seem definitive enough to provide a distinction, However, there is one significant difference that seems to be most indicative that the call with the ACL contains an acl parameter (i.e., PUT /some/path/to/bucket?acl).

For the time being I "patched" my code locally by checking if there is an acl parameter, and if so ignore the payload and return the S3Object that was generated when the file data was uploaded. I do believe though that it should be handled somehow (perhaps the ACL is required somewhere else - I just did not encounter such a need).

As a side-note - I looked for some documentation on this REST call but could not find any (I did not look very deep though due to lack of time...)

lgoldstein avatar Feb 10 '20 18:02 lgoldstein

Thanks for the thorough report!

I think adding a method that has a query parameter „acl“ defined should do the trick to route that call to that other method.

Would you like to try adding that in a PR?

agudian avatar Feb 10 '20 19:02 agudian

Would you like to try adding that in a PR?

I would love to, but I am swamped - I barely had enough time to diagnose this problem. Furthermore, I am not sure how the new method that handles it should behave:

  • Should it store the data ?
  • If so - where ? how ? when will it be read ? (I did not check if S3Browser asks for it...)

lgoldstein avatar Feb 11 '20 18:02 lgoldstein

Just released 2.7.0 which adds ObjectAcl support.

afranken avatar Sep 26 '22 13:09 afranken