spree / spree

An open source eCommerce platform giving you full control and customizability. Modular and API-first. Build any eCommerce solution that your business requires. Developed by @vendo-dev
https://spreecommerce.org
Other
12.92k stars 4.94k forks source link

Images broken on Brazilian S3 Bucket #4290

Closed alexandremcosta closed 10 years ago

alexandremcosta commented 10 years ago

Hi, Its in ruby 2.0.0, and rails 4.0.0. I have this on my spree (2-1-stable) initializer:

Spree.config do |config|
  (...)
  config.use_s3 = true
  config.s3_bucket = 'XXX'
  config.s3_access_key = "XXX"
  config.s3_secret = "XXX"
  config.attachment_url = ":sa_east_1"
  config.s3_host_alias = "s3-sa-east-1.amazonaws.com"
end

Paperclip.interpolates(:sa_east_1) do |attachment, style|
  "#{attachment.s3_protocol}://#{Spree::Config[:s3_host_alias]}/#{attachment.bucket_name}/#{attachment.path(style).gsub(%r{^/},"")}"
end

But images url are being constructed as: //s3.amazonaws.com/gobooks/app/...

The weird thing is that they are being uploaded to S3, as I can see on my amazon dashboard. They just can't be retrieved, since the image path is wrong.

PS.: when I change to a bucket on the default american location, and remove the attachment_url and s3_host_alias, it works.

Thanks in advance, Alexandre

radar commented 10 years ago

Hi @alexandremcosta,

Do you have an example of what the full broken URL looks like with these settings, and what the full correct URL looks like?

Thanks!

alexandremcosta commented 10 years ago

Sorry brow, I already moved my bucket to USA, since I couldn't let my images broken. But I remember that the URL genereted was the same URL as if my bucket was in USA. http://s3.amazonaws.com//bucket-name/app/public/....

Since it was in Brazil, the URLs were broken. If I manually changed (using inspect) the url to the brazilian bucket url (s3-sa-east-1.amazonaws.com), I could access the image.

It's weird that I could upload images to the right URL. I just couldn't retrieve the right link to access the image, via the image helpers (small_image, etc...) (it kept being genereted as s3.amazonaws.com instead of s3-sa-east-1.amazonaws.com).

radar commented 10 years ago

@alexandremcosta What version of Spree was this happening on?

alexandremcosta commented 10 years ago

I'm not sure. Right now, I'm using 2.1.4, but when this happened, it could be any 2-1-stable version before 2.1.4.

Well, if this isn't happening anymore in 2.1.4, I think we could close this issue, don't you think so?

On Ter, Mar 25, 2014 at 9:26 , Ryan Bigg notifications@github.com wrote:

@alexandremcosta What version of Spree was this happening on?

— Reply to this email directly or view it on GitHub.

radar commented 10 years ago

@alexandremcosta This might very well still be an issue. Let's leave it open.

JDutil commented 10 years ago

I'm closing this out as s3 support was removed from spree in favor of just setting up your rails application for s3. If people continue running into issues it seems to be more of a paperclip issue than spree, but can file a new issue with steps to reproduce.