ActiveStorage: Using upload_preset with folder creates invalid image links

Abierto
#423 3 comentarios 0 reacciones 1 asignado Ver en GitHub

@const-cloudinary ya está trabajando en esto.

Desde el 31/8/2020.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

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!

Lenguaje dominante
Ruby
Estrellas
420
Forks
282
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de cloudinary/cloudinary_gem

Todos los issues de cloudinary/cloudinary_gem

Issues similares

Más issues de Ruby

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.