rails-activestorage

Rails 5.2 Active Storage purging/deleting attachments

萝らか妹 提交于 2019-11-27 23:41:51
So I'm using Active Storage to upload multiple images attached to a Collection model. Everything works well except whenever I'm trying to purge/delete a single attachment from a collection. The problem: For some reason all my images immediately get purged/deleted whenever I load the show page of a collection. Of course I only want to delete a file whenever I click the link. Does anyone know how to solve this problem? My collection show view: <div id="gallery"> <% @collection.images.each do |image| %> <%= image_tag(image) %> <%= link_to 'Remove image', image.purge %> <% end %> </div> I've read

How to retrieve attachment url with Rails Active Storage with S3

我怕爱的太早我们不能终老 提交于 2019-11-27 14:58:34
问题 rails version 5.2 I have a scenario that I need to access the public url of Rails Active Storage with Amazon s3 to make a zip file with Sidekiq background job. I am having difficulty getting the actual file url. I have tried following rails_blob_url but it gives me following http://localhost:3000/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBZUk9IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--9598613be650942d1ee4382a44dad679a80d2d3b/sample.pdf How do I access the real file url

How to specify a prefix when uploading to S3 using activestorage's direct upload?

半腔热情 提交于 2019-11-27 14:10:50
With a standard S3 configuration: AWS_ACCESS_KEY_ID: [AWS ID] AWS_BUCKET: [bucket name] AWS_REGION: [region] AWS_SECRET_ACCESS_KEY: [secret] I can upload a file to S3 (using direct upload) with this Rails 5.2 code (only relevant code shown): form.file_field :my_asset, direct_upload: true This will effectively put my asset in the root of my S3 bucket, upon submitting the form. How can I specify a prefix (e.g. "development/", so that I can mimic a folder on S3)? Sorry, that’s not currently possible. I’d suggest creating a bucket for Active Storage to use exclusively. My current workaround (at

How to specify a prefix when uploading to S3 using activestorage's direct upload?

本秂侑毒 提交于 2019-11-26 16:32:05
问题 With a standard S3 configuration: AWS_ACCESS_KEY_ID: [AWS ID] AWS_BUCKET: [bucket name] AWS_REGION: [region] AWS_SECRET_ACCESS_KEY: [secret] I can upload a file to S3 (using direct upload) with this Rails 5.2 code (only relevant code shown): form.file_field :my_asset, direct_upload: true This will effectively put my asset in the root of my S3 bucket, upon submitting the form. How can I specify a prefix (e.g. "development/", so that I can mimic a folder on S3)? 回答1: Sorry, that’s not currently