Closed santib closed 5 years ago
What if this would be directly part of ActiveStorage in Rails?
user.avatar.attach(base64: 'xxxdataxxx', filename: 'avatar.png')
user.avatar = { base64: 'xxxdataxxx', filename: 'avatar.png' }
What do you think to provide such pull-request into Rails active storage instead?
I think when building REST API (JSON), this would be the best native way to upload also attachments directly from the API
Hey @Laykou, I agree it wouldn't hurt to have it in ActiveStorage Rails, but I'm not sure if that PR would be welcomed by the Rails Core team. Some time ago I asked why ActiveStorage didn't support base64 out of the box to the main maintainer of ActiveStorage (https://twitter.com/santib6_/status/1126210274132885505), but per his response I don't think he has any intention to do so.
How can we help moving that library to work with rails 6 then ?
Hey @kwent we accept PRs from the community. I started this one https://github.com/rootstrap/active-storage-base64/pull/36 some time ago, but needs a bit of polishing, so if you want to open your own PR that'd be great. Otherwise I expect to polish and finish that other PR in a couple days.
@santib Thank you ! Hope this helps a bit: https://github.com/rootstrap/active-storage-base64/pull/39
This got solved and released in version 1.0.0
of the gem 🎉
We need to add support for Rails 6.
There are some changes required in
lib/active_storage_support/support_for_base64.rb
.Ideally it should include all the changes that were done in ActiveStorage itself. For example the
has_one_attached
andhas_many_attached
methods have some changes.