ActiveStorage accepts a file as a parameter, so all you need do is get an IO handle to the remote file, something like this:
require 'open-uri'
remote = open('url/to/file').read
@my_parent_object.file = remote
@my_parent_object.save
Walter
> On Mar 23, 2018, at 7:35 AM, Anton Ipatov <ipatovanton@gmail.com> wrote:
>
> How to add ability to upload image via URL?
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/26ae9fca-3082-4250-b20e-9b8d90d6ede6%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/780C7F0B-077C-4239-A367-3095EF8EFFA2%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment