ActiveStorage: Using upload_preset with folder creates invalid image links

未關閉
#423 3 則留言 0 個 reaction 已指派 1 人 在 GitHub 檢視

@const-cloudinary 已經在處理了。

開始於 2020年8月31日。

評估

這個 Issue 還沒有評估資料。

描述

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

  1. Configure an upload preset using an upload folder (e.g. "test") in the Cloudinary administration interface.
  2. Configure Rails' storage.yml to use upload_preset: test with the configured cloudinary service (see above).
  3. Upload a file attachment via Rails and ActiveStorage, then use url_for() to generate a link to that image.
  4. 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!

主要語言
Ruby
星號
420
分支
282
PR 合併指標
30 天內沒有已合併 PR

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

cloudinary/cloudinary_gem 的其他 Issue

查看 cloudinary/cloudinary_gem 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。