Content-disposition attachment not working when host url is set

Hi, I’m new to Shrine, and I’m trying to make certain files downloadable. it works fine until I add a “host” to the url options. S3 throws the following error “SignatureDoesNotMatch”. Is this intended behavior? Any insight would be appreciated. Thanks in advance.

<%= false, host: “”, response_content_disposition: “attachment”) %>

The default “host” should already use the correct AWS S3 domain, that’s handled in the aws-sdk-s3 gem. If you need to override the default host, setting the :endpoint when initializing the storage should be the correct thing to do: "", ...)

The :host option is meant for setting CDN hosts.

Janko, thanks so much for the response and thanks for the great gem, btw.

I should’ve been more specific. I am actually using the cloudfront cdn, the url I provided was just an example. This would be a more accurate example…

<%= false, host: “”, response_content_disposition: “attachment”) %>

Also, I can get content-disposition inline using the cdn, but not "attachment’.

Hopefully this clarifies the issue.

Thanks again.

Also, I can get content-disposition inline using the cdn, but not "attachment’.

By this you mean, if you specify response_content_disposition: "inline", you don’t get the signature error?

I think non-public (signed) URLs won’t work by default with CloudFront, you probably need to do some additional configuration to make it work. This section has some info on this.


That did it! The extra config using `Aws::CloudFront::UrlSigner’ did the trick.
Thank you so much for taking the time to help.

1 Like