Active Storage uploading files from a remote location

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Active Storage uploading files from a remote location

Anton Ipatov
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 [hidden email].
To post to this group, send email to [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: Active Storage uploading files from a remote location

Walter Lee Davis
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 <[hidden email]> 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 [hidden email].
> To post to this group, send email to [hidden email].
> 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 [hidden email].
To post to this group, send email to [hidden email].
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.