![]() Using the above changes, we can do something like this. There is a Pull request that was merged to support this. This would allow you to configure multiple Cloudinary configurations in the storage.yml file which can then be configured per attachment. However, the developers working on Rails/Active Storage have a planned update in the upcoming versions to support defining multiple Active Storage adapters for the same service. This functionality is supported on Cloudinary itself, but due to the constraint with how standard Active Storage services are integrated, it means it's currently not supported through Active Storage. As a Storage service, its main function is to store files on the integrated service, but Active Storage is not able to support many custom upload flows, such as dynamic changing of the Storage path (folder) per upload. The Cloudinary Active Storage service is implemented similar to other Storage providers, such as Azure Storage, Google Cloud Storage or Amazon S3. If what you're looking for is not a base folder, but rather to dynamically change the folder for uploaded files per-upload, then, in short, that isn't supported. To do that, you would add the folder option and set it to the folder in which you would like the Cloudinary service to upload the resources to - cloudinary_gallery: If you would like to upload files to a different base folder then you can configure that in the storage.yml file. This would provide an easy way to identify and deal with such images.īy default, Cloudinary Active Storage service uploads to the root of the Cloudinary account. The reason for this is that I am using direct_upload and it is possible for users to upload photos without ever creating a post. What I want to do is store the resized photos in a different folder. ![]() I am taking this approach to avoid integrity errors that take place resizing a post directly on Cloudinary after upload. What the above job is doing is waiting until after a post is created and then resizing and reattaching the photos to the post well deleting the originals. nd(:images).attach io: StringIO.new(new_data), filename: _s, Pipeline = ImageProcessing::MiniMagick.source(path) I have seen that setting a custom folder header may be a way to get this to work, but again cannot figure out how to set a custom header for the above code which takes place in the below job. I have tried my best to read both ActiveStorage and Cloudinary docs in an attempt to find a way to make this work, however, I cannot seem to figure it out. It does not accept an argument to specify the folder. I am using the following code to attach images nd(:images).attach io: StringIO.new(new_data), filename: _s, However, I am using ActiveStorage, and when I upload a photo in the above manner it isn't attached to my Post model or associated in any way with my app. Cloudinary::Uploader.upload("sample.jpg", :use_filename => true, :folder => "folder1/folder2") I understand how this can be down when uploading directly to Cloudinary using the below syntax and passing the folder name as an argument.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |