Hi Tim,

It has been a very long time since I last looked at this code. It is a good 
thing that at least part of it still works.

Just by reading the code and reasoning about your problem, I would suggest you 
try the following change:

In ZnAWSS3RequestSignatureTool>>#canonicalStringFor: replace the last 

 request uri pathPrintString

by

 request uri pathQueryFragmentPrintString

I did not try this myself, so it might not solve your issue.

Please let me know if this works.

Sven

> On 17 Jun 2021, at 03:05, Tim Mackinnon <tim@testit.works> wrote:
> 
> Hi everyone - I’m wondering if someone knows the trick to listing object 
> versions in AWS S3?
> 
> I was previously using a non-Zn library (there are a few around - but they 
> are quite old and I’m not sure how much they are maintained) - however I 
> hadn’t realised that Zn actually supports S3 until I read it a bit carefully 
> and realised that I needed to load an extra AWS group.
> 
> So - I have a bucket that is versioned, and I wanted to read the versions of 
> an object - and hopefully be able to read the contents of an older version.
> 
> I can list the contents of a bucket, but when I try to read the versions of 
> an object - I get a forbidden error - which when I dig deeper gives a 
> stranger explanation?
> 
> I have confirmed that the AWS CLI is able to list versions in that bucket - 
> so I’m a bit confused what the issue might be?
> 
> (client := ZnAWSS3Client new)
>       accessKeyId: 'xxx';
>       secretAccessKey: ‘yyyyy';
>       checkIntegrity: true.
> 
> client buckets. “Works"
> client keysIn: 'mtt-data’. “Works"
> 
> client at: 'mtt-data' -> 'sample.txt’. “Works"
> 
> client keysIn: 'mtt-data' query: (Dictionary with: 'versions'->nil). “Gives 
> an error?”
> 
> 
> HTTP/1.1 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><AWSAccessKeyId>xxx</AWSAccessKeyId><StringToSign>GET
> 
> 
> Has anyone tried doing this - I’m sure there is something really simple that 
> I am missing?
> 
> Tim

Reply via email to