403 Forbidden error on files with spaces (%20)

Feb 15, 2008 at 10:22 PM
I'm having a problem using this library when the file contains spaces. All files without spaces are getting uploaded fine, but when it comes across a file with spaces (which have been converted to %20, I get the following:

The remote server returned an error: (403) Forbidden.

<?xml version="1.0" encoding="UTF-8" ?>
- <Error>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
<RequestId>58065141C263033E</RequestId>
<SignatureProvided>TkuHrQc2VY4RbEECGbf9a7MsMqs=</SignatureProvided>
<StringToSignBytes>50 55 54 0a 0a 69 6d 61 67 65 2f 6a 70 65 67 0a 0a 78 2d 61 6d 7a 2d 64 61 74 65 3a 53 75 6e 2c 20 31 30 20 46 65 62 20 32 30 30 38 20 30 37 3a 35 37 3a 35 33 20 47 4d 54 0a 2f 6d 73 77 5f 70 69 63 74 75 72 65 73 2f 43 68 61 72 6c 69 65 25 32 30 61 6e 64 25 32 30 44 61 64 25 32 30 63 6f 6f 6b 69 6e 67 25 32 30 62 72 65 61 6b 66 61 73 74 2e 6a 70 67</StringToSignBytes>
<AWSAccessKeyId>0GP714KD16C2GKAP1782</AWSAccessKeyId>
<HostId>pnKWs0ISNN3WxkwvDo8FNLRxjQFfs10l5QUJPXKmELpDF+B66zSNucw6V4CEvsN9</HostId>
<StringToSign>PUT image/jpeg x-amz-date:Sun, 10 Feb 2008 07:57:53 GMT /msw-pictures/Charlie%20and%20Dad%20cooking%20breakfast.jpg</StringToSign>
</Error>

Any ideas? I have tested this with version 1.1 and just tried it again with 1.2.

Thanks,

Charlie
Feb 19, 2008 at 6:11 PM
I suspect this is due to the key (filename) not getting encoded properly when forming the canonical string for the authentication header. I ran into this problem last week and submitted it to the Issue Tracker here this morning (see http://www.codeplex.com/ThreeSharp/WorkItem/View.aspx?WorkItemId=9353). If spaces are the only character you are using that requires encoding you can probably fix this by modifying MakeCanonicalString in ThreeSharpUtils.cs so it replaces spaces in the key with "%20".