Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Paperclip generating wrong url of file uploaded on S3 bucket #2659

Open
hasannadeem opened this issue Mar 16, 2020 · 0 comments
Open

Paperclip generating wrong url of file uploaded on S3 bucket #2659

hasannadeem opened this issue Mar 16, 2020 · 0 comments

Comments

@hasannadeem
Copy link

When the file gets uploaded on S3 then the response from S3 bucket contains the correct url of the uploaded file. But paperclip is generating a different url from the actual one.

The correct url is something like this: https://s3-us-west-2.amazonaws.com/my-bucket-local/uploads%2F1583953531486-lj6zdckcsj-9d6384a03fcd96941890332878d5a350%2F8481.jpg

But paperclip's url for document.file.url is: //s3.amazonaws.com/my-bucket-local/documents/files/000/000/032/original/8481.jpg OR https://my-bucket-local.s3.us-west-2.amazonaws.com/documents/files/000/000/026/original/8481.jpg with few more params like X-Amz-Algorithm + X-Amz-Credential etc.

In my Document model, I have has_attached_file :file

Following is the configuration for development environment in my development.rb file

config.paperclip_defaults = {
  storage: :s3,
  s3_region: ENV['AWS_REGION'],
  s3_credentials: {
    bucket: ENV['AWS_BUCKET'],
    access_key_id: ENV['AWS_ACCESS_KEY_ID'],
    secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
  },
}

In my s3 bucket, there's only an uploads folder and it contains multiple subfolders with unique identifiers as their titles and each subfolder contains the actual file image.

Deprecation notice

Paperclip is currently undergoing deprecation in favor of ActiveStorage. Maintainers of this repository will no longer be tending to new issues. We're leaving the issues page open so Paperclip users can still see & search through old issues, and continue existing discussions if they wish.

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

No branches or pull requests

1 participant