[ 
https://issues.apache.org/jira/browse/JCLOUDS-1447?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16611778#comment-16611778
 ] 

Rami Hänninen commented on JCLOUDS-1447:
----------------------------------------

First, I would respectfully argue that this is quite serious error, and would 
deserve higher priority than 'Minor'. This issue effectively prevents any use 
of S3 paths with any "unsafe" characters in them (anything that URL encoding 
would apply encoding to).

My analysis would suggest that the main cause for this is that 
'core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java' 
(part of jclouds REST API core framework) does not provide any means to apply 
selected encodings on selected headers. In this particular case, Amazon S3 REST 
API specifies that the values of custom 'x-amz-copy-source' headers must be URL 
encoded, but the underlying jclouds REST API declaration system just can't 
handle this.

I think also that this issue has much wider scope that this one particular 
Amazon S3 specific 'x-amz-copy-source' header, and 'copyObject' operation, 
because there are number of other Amazon S3 headers that need to be URL 
encoded, too, in a number of other operations that need appropriate header 
encoding. It is also likely that some other REST API operations somewhere else 
require also that some other headers need to be encoded, possible with some 
other encoding mechanism than URL encoding. However, I'm not familiar with 
other storage systems REST API than Amazon S3, so I can only hazard a guess 
here.

I would humbly suggest that the current Headers annotation (in 
'core/src/main/java/org/jclouds/rest/annotations/Headers.java') and the related 
'addHeader' private method in 'RestAnnotationProcessor.java' would be extended 
so that it would be possible to specify what, if any, encoding is to be applied 
on each header, and then the corresponding declarations that involve headers 
that must be so encoded (like 'copyObject' in 
'apis/s3/src/main/java/org/jclouds/s3/S3Client.java') would be updated to use 
this new annotation feature.

A guess a number of unit tests would have to be updated, too, and new ones that 
would test this new feature would have to be added, too.

Thank you for your consideration and efforts on fixing this issue.

> S3 CopyObject requires x-amz-copy-source to be URL encoded
> ----------------------------------------------------------
>
>                 Key: JCLOUDS-1447
>                 URL: https://issues.apache.org/jira/browse/JCLOUDS-1447
>             Project: jclouds
>          Issue Type: Bug
>          Components: jclouds-blobstore
>    Affects Versions: 2.1.1
>            Reporter: David Currie
>            Priority: Minor
>              Labels: s3
>
> S3 CopyObject requires x-amz-copy-source to be URL encoded as per 
> [https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectCOPY.html.] 
> Current failure to do so results in a 400:
> {code}
> org.jclouds.aws.AWSResponseException: request PUT 
> https://cloudbees-kubernetes-arch.s3.amazonaws.com/jclouds-test/…/test0/2/artifacts/otherdir/xxx%23%3F:%24%26%27%22%3C%3E%C4%8D%E0%A5%90
>  HTTP/1.1 failed with code 400, error: AWSError\{requestId='…', 
> requestToken='…', code='InvalidArgument', message='Unsupported copy source 
> parameter.', 
> context='{ArgumentValue=/cloudbees-kubernetes-arch/jclouds-test/…/test0/1/artifacts/otherdir/xxx#?:$&'"<>čॐ,
>  HostId=…, ArgumentName=x-amz-copy-source}'}
>  at 
> org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent.handleError(ParseAWSErrorFromXmlContent.java:75)
>  at …
>  at org.jclouds.s3.blobstore.S3BlobStore.copyBlob(S3BlobStore.java:324)
> {code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to