rootstrap / active-storage-base64

Base64 support for ActiveStorage
https://rootstrap.com
MIT License
160 stars 16 forks source link

Support Rails 6 #31

Closed santib closed 5 years ago

santib commented 5 years ago

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 and has_many_attached methods have some changes.

Laykou commented 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

santib commented 5 years ago

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.

kwent commented 5 years ago

How can we help moving that library to work with rails 6 then ?

santib commented 5 years ago

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.

kwent commented 5 years ago

@santib Thank you ! Hope this helps a bit: https://github.com/rootstrap/active-storage-base64/pull/39

santib commented 5 years ago

This got solved and released in version 1.0.0 of the gem 🎉