ActiveStorage: Using upload_preset with folder creates invalid image links
@const-cloudinary is already working on this.
Since Aug 31, 2020.
Assessment
This issue has not been assessed yet.
Description
Describe the bug in a sentence or two.
I use different upload presets in my app which default to a different folder each (e.g. "production").
storage.yml:
cloudinary:
service: Cloudinary
upload_preset: <%= ENV['CLOUDINARY_UPLOAD_PRESET'] %>
What the SDK cannot know is that the upload preset is configured to upload files into a specified folder. Therefore, when it generates links to the uploaded images, they miss the folder part and result in dead links.
Issue Type
[ ] Build - Can’t install or import the SDK
[ ] Performance - Performance issues
[X] Behaviour - Functions aren’t working as expected (Such as generate URL)
[ ] Documentation - Inconsistency between the docs and behaviour
[ ] Other (Specify)
Steps to reproduce
- Configure an upload preset using an upload folder (e.g. "test") in the Cloudinary administration interface.
- Configure Rails' storage.yml to use
upload_preset: testwith the configured cloudinary service (see above). - Upload a file attachment via Rails and ActiveStorage, then use url_for() to generate a link to that image.
- Observe: the link misses the "test"-folder part.
Operating System
[ ] Linux
[ ] Windows
[ ] OSX
[X] All
Environment and Libraries
Cloudinary Ruby SDK version - 1.13.2
Ruby Version - 2.6.6
Rails Version - 5.2.4.1
ActiveStorage - 5.2.4.1
Suggestion
We could use the Cloudinary API to fetch the configured upload folder for the specified upload preset. I'm not sure that's a good idea - we might end up calling the API every time someone uses an upload_prefix.
We may also introduce another storage.yml option "preset_folder" to be used together with upload_preset only.
I need this fixed quite urgently so I'm absolutely willing to submit a PR. Any hints from the maintainers would be totally helpful!
- Dominant language
- Ruby
- Stars
- 420
- Forks
- 282
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cloudinary/cloudinary_gem
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
cloudinary/cloudinary_gem#597 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
cloudinary/cloudinary_gem#591 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
cloudinary/cloudinary_gem#582 · 1 comment ·
-
404's when fetching .eml files (from Action Mailbox)May be free again @rnamba-cloudinary claimed this 400 days ago, and no pull request is open. Open
Difficulty 4/5 3-5 days Newbie friendliness 30/100
cloudinary/cloudinary_gem#581 · 1 comment ·
-
BlobKey, MirrorService and Sidekiq 8 are incompatibleMay be free again @const-cloudinary claimed this 541 days ago, and no pull request is open. Open
cloudinary/cloudinary_gem#573 · 3 comments · 1 assignee ·
All issues in cloudinary/cloudinary_gem
Similar issues
-
releases.rb silent failure cascades into NoMethodError crashes in downstream extensionsPossibly taken @Rucha0901 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
jenkins-infra/jenkins.io#9598 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
yegor256/mailanes#361 · 1 comment ·
Maintainers usually reply within 1 day
-
Property accounts have no notes fieldPossibly taken @arnaurodondev claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
we-promise/sure#5057 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
metacall/core#964 · 1 comment ·
Maintainers usually reply within 1 day
-
Mend: dependency security vulnerability
Difficulty 1/5 Under an hour Newbie friendliness 80/100