File uploading with ActiveStorage in Rails 5.2 Discussion
Regarding images attached to another model- 9 times out of 10, I have to include additional meta-data with a file upload (a title, a caption, a photo credit, etc.). Does ActiveStorage make that less of a headache in situations like a Post having multiple uploads (as you have demonstrated in this episode)? Thanks!
However, once it gets generated and saved to disk, then it is read from storage. So, the calculation only happens once.
Does anyone know if there's a way to send the preview request to a background job on upload? so something like sidekiq will handle generating and saving the preview when the file is uploaded and not waiting until a user requests the preview and making them wait?
Does ActiveStorage provide a solution to process uploads on upload and not on-the-fly? For ex. processing video-files could be time-consuming and good to be done on upload.
If there is no option to process on upload, is there a reason to prefer on-the-fly processing?
How does one retain an upload if the form redisplays, say if you have validation error on one of the attributes of the form model? Shrine has a Plugin for that, is there something you could do to make caching work with Active Storage?
mogrify: unrecognized option `-resize-to-fit' @ error/mogrify.c/MogrifyImageCommand/5892.
I'm using mini_magick 4.8.0. Any help will be appreciated. I also tried gem "image_processing" but had the same errors.
Is this related: https://github.com/janko-m/image_processing/issues/39
Thanks a lot Chris. Great stuff.
I was wondering what's the ideal way to delete/purge/destroy one or more attachments, if using Active Storage. Can you please share your ideas?
I am having no difficulties with my local setup and getting this to work. However, I am getting errors on my Heroku app on production. I watched the tutorial on Encrypted Credentials which was fantastic but unfortunately it didn't solve my issue. My storage.yml file looks like the following:
digitalocean: service: S3 access_key_id: <%= Rails.application.credentials.dig(:digitalocean, :access_key_id) %> secret_access_key: <%= Rails.application.credentials.dig(:digitalocean, :secret_access_key) %> bucket: ted-blog region: nyc3 endpoint: <%= Rails.application.credentials.dig(:digitalocean, :endpoint_address) %> ``` If anyone has an insight into what might be the problem, I'd be grateful. Thanks!
Hello Chris, I love your videos. I was wondering if there is an easy way to upload files manually using ActiveStorage since I can not find it in the documentation. Thanks in advanced.
Am I right that a new upload copies over (or deletes) previous uploads even with had_many?
Second question. Is there any way to associate a title or caption with the uploaded image?
PS. Great video, helped me with setting up ActiveStorage. I updated to 5.2 to get AS.
I created a secondary model
Attachments to add has_attached to so I could add additional fields. The issue is that there no easy way to validate the presence of an attachment. Also when my validation on the other fields fails the previously uploaded file does not seem to persist to the render :edit page.
What if I want uploading files as non-attachment?
Can't find information on ActiveStorage documentation.
I can't get variant(size: "") to work while using a cloud provider in production.
I need to user.avatar.service_url.split("?").first to get the right path for the img but when I do this, I can't use variant because that path is a string.
Any idea how I overcome this.
Hi Chris, thanks for this video and the one on migrating from Paperclip. Can you address how we might setup ActiveStorage for multiple environments? I have one s3 bucket for production and one for staging. What I want to be able to do is display production images when on staging (or development), but if I update an image while on staging/development have that not affect production. That way I can pull a copy of my production db and load it to staging and have staging not full of broken images. I came across this article for migrating from Paperclip which had an interesting idea to achieve this, but it's not fleshed out enough for me to follow. Any help would be appreciated.