Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

temporary_url method throws URI::InvalidURIError or an AWS SignatureDoesNotMatch #51

Open
empika opened this issue Jul 13, 2011 · 0 comments
Labels

Comments

@empika
Copy link

empika commented Jul 13, 2011

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant