temporary_url method throws URI::InvalidURIError or an AWS SignatureDoesNotMatch
empika opened this issue · 0 comments
empika commented
Hi
I'm trying to generate a temporary URL for a bucket object:
s.bucket_items[5].temporary_url
But I get the error:
URI::InvalidURIError: bad URI(is not URI?): /files/file.text
It looks like the temporary_url method needs to pass the host param to Signature.generate_temporary_url_signature:
def temporary_url(expires_at = Time.now + 3600)
uri = URI.parse(self.url)
signature = Signature.generate_temporary_url_signature(:bucket => name,
:resource => URI.escape(key),
:expires_at => expires_at,
:secret_access_key => secret_access_key,
:host => uri.host)
"#{url}?AWSAccessKeyId=#{self.bucket.service.access_key_id}&Expires=#{expires_at.to_i.to_s}&Signature=#{signature}"
end
However this does not fix the problem. Any URLs generated with this will throw a SignatureDoesNotMatch from Amazon.
I've looked for AWS docs on how to generate signed expiring URL's but cant find any.
Any ideas on how to fix this issue?
Cheers