Ask A Question


You’re not receiving notifications from this thread.

File uploads in Rails with Shrine Discussion

has anyone used Shrine and Backblaze B2 storage?


Can Shrine make files secure? Ideally, selecting which file attachments are secure and which are public should be possible. Currently hard to do with ActiveStorage as you have to select it for all the attachments. Which is quite Basecamp centric in it's thinking.


yes it can

I have mine setup this way

Shrine.storages = {
cache: "#{ENV["CREDENTIALS_ENV"]}/cache", **s3_options),
store: "#{ENV["CREDENTIALS_ENV"]}/store", **s3_options),
public_store: true, upload_options: { cache_control: "max-age=15552000" }, prefix: "#{ENV["CREDENTIALS_ENV"]}/public", **s3_options)


you should use a gem like lockbox ( if you want to encrypt your files. It even has instructions for working with Shrine if you look at the docs.


What’s the story with Shrine if an application is also using Action Text?


I think that this episode can help you or at least give you some guidance!


Thank you for making these videos! They've been helpful. But what if the photos (multiple) are being added as a nested attribute on another model's create action? I've had so much trouble understanding this😫


This is another video that covers what you need!


Guys, I'm trying to get shrine to work with my rails api but I can't figure out what I'm messing.

I'm able to upload the file but the image_data that is return doesn't go to my image_data column. It gives me a JSON Parse error 783. What I'm supposed to do? Store the image_data as a string (eg. "{\"id\":\"89966472375f0c62dd2f8404da931d84.jpg\",\"storage\":\"cache\",\"metadata\"...) or what?

I'm using a SPA as front-end. The problem is when I try to use the uploaded file into the model that have the atacched file metadata.


Ok, I changed PG column to json and now it works. Some tutorials I read stated to use string and not json but it works fine, so I guess that's it.

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 84,256+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.