How do I create an image object from a remote image url

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

How do I create an image object from a remote image url

fugee ohu
How do I create an image object from a remote image url in rails console

--
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/89de209d-5deb-4c12-ba2e-2ea98a17db18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How do I create an image object from a remote image url

Colin Law
On Mon, 29 Oct 2018 at 05:08, fugee ohu <[hidden email]> wrote:
How do I create an image object from a remote image url in rails console

What do you mean by image object?

Colin
 

--
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/89de209d-5deb-4c12-ba2e-2ea98a17db18%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/CAL%3D0gLtxE_m35waeKDzh362m%3DUCo8a9nxJNf8h3%3D9Y5YuOYuZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How do I create an image object from a remote image url

fugee ohu


On Monday, October 29, 2018 at 4:48:42 AM UTC-4, Colin Law wrote:
On Mon, 29 Oct 2018 at 05:08, fugee ohu <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="A9-cva6CBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">fuge...@...> wrote:
How do I create an image object from a remote image url in rails console

What do you mean by image object?

Colin
 

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="A9-cva6CBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonrails-ta...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="A9-cva6CBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/89de209d-5deb-4c12-ba2e-2ea98a17db18%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/89de209d-5deb-4c12-ba2e-2ea98a17db18%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/89de209d-5deb-4c12-ba2e-2ea98a17db18%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/89de209d-5deb-4c12-ba2e-2ea98a17db18%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

 An object returned by Nokogiri as a result of selecting a css.("a") element containing  <img src="...">

--
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/6151aa32-b5bf-4d05-bc4f-242bd30ec6a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How do I create an image object from a remote image url

Colin Law
On Mon, 29 Oct 2018 at 11:54, fugee ohu <[hidden email]> wrote:


On Monday, October 29, 2018 at 4:48:42 AM UTC-4, Colin Law wrote:
On Mon, 29 Oct 2018 at 05:08, fugee ohu <[hidden email]> wrote:
How do I create an image object from a remote image url in rails console

What do you mean by image object?


 An object returned by Nokogiri as a result of selecting a css.("a") element containing  <img src="...">

That doesn't make sense, you ask how to create an image object, then say that an image object is an object returned by nokogiri.  So to create it all you have to do is make that request to nokogiri.

Colin

--
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/CAL%3D0gLtKZtrS7Uc5jNDu-Mw1NCp6ciGuf9w2ni-%3D8nbBqP2PxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How do I create an image object from a remote image url

Ryan-2
In reply to this post by fugee ohu
https://github.com/carrierwaveuploader/carrierwave#uploading-files-from-a-remote-location


On Sunday, October 28, 2018 at 10:08:19 PM UTC-7, fugee ohu wrote:
How do I create an image object from a remote image url in rails console

--
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/a925914a-8440-40a8-9e9c-e564d9fdd7df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How do I create an image object from a remote image url

fugee ohu


On Monday, October 29, 2018 at 1:43:05 PM UTC-4, Ryan wrote:
<a href="https://github.com/carrierwaveuploader/carrierwave#uploading-files-from-a-remote-location" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fcarrierwaveuploader%2Fcarrierwave%23uploading-files-from-a-remote-location\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEUpmTUh_ENl97fHQLBHLdSCKpjUg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fcarrierwaveuploader%2Fcarrierwave%23uploading-files-from-a-remote-location\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEUpmTUh_ENl97fHQLBHLdSCKpjUg&#39;;return true;">https://github.com/carrierwaveuploader/carrierwave#uploading-files-from-a-remote-location


On Sunday, October 28, 2018 at 10:08:19 PM UTC-7, fugee ohu wrote:
How do I create an image object from a remote image url in rails console

Using  ActiveStorage but I'll look at the page thanks

--
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/0793717a-72a3-481b-8ffa-25faeef57a08%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How do I create an image object from a remote image url

fugee ohu
In reply to this post by Colin Law


On Monday, October 29, 2018 at 10:14:44 AM UTC-4, Colin Law wrote:
On Mon, 29 Oct 2018 at 11:54, fugee ohu <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="mhgxcHmUBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">fuge...@...> wrote:


On Monday, October 29, 2018 at 4:48:42 AM UTC-4, Colin Law wrote:
On Mon, 29 Oct 2018 at 05:08, fugee ohu <[hidden email]> wrote:
How do I create an image object from a remote image url in rails console

What do you mean by image object?


 An object returned by Nokogiri as a result of selecting a css.("a") element containing  <img src="...">

That doesn't make sense, you ask how to create an image object, then say that an image object is an object returned by nokogiri.  So to create it all you have to do is make that request to nokogiri.

Colin


I'm trying to insert an image into the assets table from web scraping Scraping gets me the src of the image I don't know if I should submit a form or do a raw insert in my script 

--
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/9f8ba9af-0ad0-4fd0-856b-0f236c76149b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How do I create an image object from a remote image url

Walter Lee Davis

> On Oct 29, 2018, at 10:08 PM, fugee ohu <[hidden email]> wrote:
>
>
>
> On Monday, October 29, 2018 at 10:14:44 AM UTC-4, Colin Law wrote:
> On Mon, 29 Oct 2018 at 11:54, fugee ohu <[hidden email]> wrote:
>
>
> On Monday, October 29, 2018 at 4:48:42 AM UTC-4, Colin Law wrote:
> On Mon, 29 Oct 2018 at 05:08, fugee ohu <[hidden email]> wrote:
> How do I create an image object from a remote image url in rails console
>
> What do you mean by image object?
>
>
>  An object returned by Nokogiri as a result of selecting a css.("a") element containing  <img src="...">
>
> That doesn't make sense, you ask how to create an image object, then say that an image object is an object returned by nokogiri.  So to create it all you have to do is make that request to nokogiri.
>
> Colin
>
>
> I'm trying to insert an image into the assets table from web scraping Scraping gets me the src of the image I don't know if I should submit a form or do a raw insert in my script

Read the documentation for your file upload package -- I believe you mentioned ActiveStorage -- about uploading from a URL. This is a common feature in many file attachment systems. CarrierWave, Shrine, CarrierWave, even Paperclip have a way to do this.

It usually amounts to something like

require 'open-uri'
file = open(remote_url).read
@your_instance.file = file
@your_instance.save # (the file should be persisted locally)

Walter

>
> --
> 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/9f8ba9af-0ad0-4fd0-856b-0f236c76149b%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/C58CB881-6B67-419D-94E8-FA70BF546CCA%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How do I create an image object from a remote image url

fugee ohu


On Monday, October 29, 2018 at 11:28:58 PM UTC-4, Walter Lee Davis wrote:

> On Oct 29, 2018, at 10:08 PM, fugee ohu <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="NPqtydC_BgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">fuge...@...> wrote:
>
>
>
> On Monday, October 29, 2018 at 10:14:44 AM UTC-4, Colin Law wrote:
> On Mon, 29 Oct 2018 at 11:54, fugee ohu <[hidden email]> wrote:
>
>
> On Monday, October 29, 2018 at 4:48:42 AM UTC-4, Colin Law wrote:
> On Mon, 29 Oct 2018 at 05:08, fugee ohu <[hidden email]> wrote:
> How do I create an image object from a remote image url in rails console
>
> What do you mean by image object?
>
>
>  An object returned by Nokogiri as a result of selecting a css.("a") element containing  <img src="...">
>
> That doesn't make sense, you ask how to create an image object, then say that an image object is an object returned by nokogiri.  So to create it all you have to do is make that request to nokogiri.
>
> Colin
>
>
> I'm trying to insert an image into the assets table from web scraping Scraping gets me the src of the image I don't know if I should submit a form or do a raw insert in my script

Read the documentation for your file upload package -- I believe you mentioned ActiveStorage -- about uploading from a URL. This is a common feature in many file attachment systems. CarrierWave, Shrine, CarrierWave, even Paperclip have a way to do this.

It usually amounts to something like

require 'open-uri'
file = open(remote_url).read
@your_instance.file = file
@your_instance.save # (the file should be persisted locally)

Walter

>
> --
> 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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="NPqtydC_BgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="NPqtydC_BgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/9f8ba9af-0ad0-4fd0-856b-0f236c76149b%40googlegroups.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/9f8ba9af-0ad0-4fd0-856b-0f236c76149b%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/9f8ba9af-0ad0-4fd0-856b-0f236c76149b%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/9f8ba9af-0ad0-4fd0-856b-0f236c76149b%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.


Thanks, I'll use Carrierwave because when I googled "ActiveStorage remote file upload" what I found was a discussion where someone says you can't do this in ActiveStorage but you can with Carrierwave 
 

--
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/2eebec62-614c-4d0e-9834-7c3a80bb4112%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How do I create an image object from a remote image url

Walter Lee Davis

> On Oct 30, 2018, at 12:09 PM, fugee ohu <[hidden email]> wrote:
>
>
>
> On Monday, October 29, 2018 at 11:28:58 PM UTC-4, Walter Lee Davis wrote:
>
> > On Oct 29, 2018, at 10:08 PM, fugee ohu <[hidden email]> wrote:
> >
> >
> >
> > On Monday, October 29, 2018 at 10:14:44 AM UTC-4, Colin Law wrote:
> > On Mon, 29 Oct 2018 at 11:54, fugee ohu <[hidden email]> wrote:
> >
> >
> > On Monday, October 29, 2018 at 4:48:42 AM UTC-4, Colin Law wrote:
> > On Mon, 29 Oct 2018 at 05:08, fugee ohu <[hidden email]> wrote:
> > How do I create an image object from a remote image url in rails console
> >
> > What do you mean by image object?
> >
> >
> >  An object returned by Nokogiri as a result of selecting a css.("a") element containing  <img src="...">
> >
> > That doesn't make sense, you ask how to create an image object, then say that an image object is an object returned by nokogiri.  So to create it all you have to do is make that request to nokogiri.
> >
> > Colin
> >
> >
> > I'm trying to insert an image into the assets table from web scraping Scraping gets me the src of the image I don't know if I should submit a form or do a raw insert in my script
>
> Read the documentation for your file upload package -- I believe you mentioned ActiveStorage -- about uploading from a URL. This is a common feature in many file attachment systems. CarrierWave, Shrine, CarrierWave, even Paperclip have a way to do this.
>
> It usually amounts to something like
>
> require 'open-uri'
> file = open(remote_url).read
> @your_instance.file = file
> @your_instance.save # (the file should be persisted locally)
>
> Walter
>
> >
> > --
> > 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/9f8ba9af-0ad0-4fd0-856b-0f236c76149b%40googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
>
> Thanks, I'll use Carrierwave because when I googled "ActiveStorage remote file upload" what I found was a discussion where someone says you can't do this in ActiveStorage but you can with Carrierwave
>  
>

I'd recommend Shrine. Much better documentation, current development, and a super-responsive development team.

Walter

> --
> 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/2eebec62-614c-4d0e-9834-7c3a80bb4112%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/3CF1879E-6C29-4FA4-8B6F-EDDF8D21F561%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How do I create an image object from a remote image url

fugee ohu


On Tuesday, October 30, 2018 at 1:02:59 PM UTC-4, Walter Lee Davis wrote:

> On Oct 30, 2018, at 12:09 PM, fugee ohu <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="PMg_ejzsBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">fuge...@...> wrote:
>
>
>
> On Monday, October 29, 2018 at 11:28:58 PM UTC-4, Walter Lee Davis wrote:
>
> > On Oct 29, 2018, at 10:08 PM, fugee ohu <[hidden email]> wrote:
> >
> >
> >
> > On Monday, October 29, 2018 at 10:14:44 AM UTC-4, Colin Law wrote:
> > On Mon, 29 Oct 2018 at 11:54, fugee ohu <[hidden email]> wrote:
> >
> >
> > On Monday, October 29, 2018 at 4:48:42 AM UTC-4, Colin Law wrote:
> > On Mon, 29 Oct 2018 at 05:08, fugee ohu <[hidden email]> wrote:
> > How do I create an image object from a remote image url in rails console
> >
> > What do you mean by image object?
> >
> >
> >  An object returned by Nokogiri as a result of selecting a css.("a") element containing  <img src="...">
> >
> > That doesn't make sense, you ask how to create an image object, then say that an image object is an object returned by nokogiri.  So to create it all you have to do is make that request to nokogiri.
> >
> > Colin
> >
> >
> > I'm trying to insert an image into the assets table from web scraping Scraping gets me the src of the image I don't know if I should submit a form or do a raw insert in my script
>
> Read the documentation for your file upload package -- I believe you mentioned ActiveStorage -- about uploading from a URL. This is a common feature in many file attachment systems. CarrierWave, Shrine, CarrierWave, even Paperclip have a way to do this.
>
> It usually amounts to something like
>
> require 'open-uri'
> file = open(remote_url).read
> @your_instance.file = file
> @your_instance.save # (the file should be persisted locally)
>
> Walter
>
> >
> > --
> > 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-ta...@googlegroups.com.
> > To post to this group, send email to [hidden email].
> > To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/9f8ba9af-0ad0-4fd0-856b-0f236c76149b%40googlegroups.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/9f8ba9af-0ad0-4fd0-856b-0f236c76149b%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/9f8ba9af-0ad0-4fd0-856b-0f236c76149b%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/9f8ba9af-0ad0-4fd0-856b-0f236c76149b%40googlegroups.com.
> > For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.
>
>
> Thanks, I'll use Carrierwave because when I googled "ActiveStorage remote file upload" what I found was a discussion where someone says you can't do this in ActiveStorage but you can with Carrierwave
>  
>

I'd recommend Shrine. Much better documentation, current development, and a super-responsive development team.

Walter

> --
> 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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="PMg_ejzsBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="PMg_ejzsBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/2eebec62-614c-4d0e-9834-7c3a80bb4112%40googlegroups.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/2eebec62-614c-4d0e-9834-7c3a80bb4112%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/2eebec62-614c-4d0e-9834-7c3a80bb4112%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/2eebec62-614c-4d0e-9834-7c3a80bb4112%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.


With 'require open-uri' i can just use ActiveStorage don't need to use a gem?   

--
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/30ffe7c3-39b5-43eb-a232-94fb8e5696de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How do I create an image object from a remote image url

Walter Lee Davis

> On Oct 30, 2018, at 1:11 PM, fugee ohu <[hidden email]> wrote:
>
>
>
> On Tuesday, October 30, 2018 at 1:02:59 PM UTC-4, Walter Lee Davis wrote:
>
> > On Oct 30, 2018, at 12:09 PM, fugee ohu <[hidden email]> wrote:
> >
> >
> >
> > On Monday, October 29, 2018 at 11:28:58 PM UTC-4, Walter Lee Davis wrote:
> >
> > > On Oct 29, 2018, at 10:08 PM, fugee ohu <[hidden email]> wrote:
> > >
> > >
> > >
> > > On Monday, October 29, 2018 at 10:14:44 AM UTC-4, Colin Law wrote:
> > > On Mon, 29 Oct 2018 at 11:54, fugee ohu <[hidden email]> wrote:
> > >
> > >
> > > On Monday, October 29, 2018 at 4:48:42 AM UTC-4, Colin Law wrote:
> > > On Mon, 29 Oct 2018 at 05:08, fugee ohu <[hidden email]> wrote:
> > > How do I create an image object from a remote image url in rails console
> > >
> > > What do you mean by image object?
> > >
> > >
> > >  An object returned by Nokogiri as a result of selecting a css.("a") element containing  <img src="...">
> > >
> > > That doesn't make sense, you ask how to create an image object, then say that an image object is an object returned by nokogiri.  So to create it all you have to do is make that request to nokogiri.
> > >
> > > Colin
> > >
> > >
> > > I'm trying to insert an image into the assets table from web scraping Scraping gets me the src of the image I don't know if I should submit a form or do a raw insert in my script
> >
> > Read the documentation for your file upload package -- I believe you mentioned ActiveStorage -- about uploading from a URL. This is a common feature in many file attachment systems. CarrierWave, Shrine, CarrierWave, even Paperclip have a way to do this.
> >
> > It usually amounts to something like
> >
> > require 'open-uri'
> > file = open(remote_url).read
> > @your_instance.file = file
> > @your_instance.save # (the file should be persisted locally)
> >
> > Walter
> >
> > >
> > > --
> > > 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/9f8ba9af-0ad0-4fd0-856b-0f236c76149b%40googlegroups.com.
> > > For more options, visit https://groups.google.com/d/optout.
> >
> >
> > Thanks, I'll use Carrierwave because when I googled "ActiveStorage remote file upload" what I found was a discussion where someone says you can't do this in ActiveStorage but you can with Carrierwave
> >  
> >
>
> I'd recommend Shrine. Much better documentation, current development, and a super-responsive development team.
>
> Walter
>
> > --
> > 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/2eebec62-614c-4d0e-9834-7c3a80bb4112%40googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
>
> With 'require open-uri' i can just use ActiveStorage don't need to use a gem?  
>

Open-URI is part of the Ruby standard library, not a third-party Gem. If you are in a Rails app, you won't need to do this, because it's part of the requirements. But if you are building a stand-alone script for testing, as you should, you may need to do this before the Kernel.open command will open a URI.

Walter

> --
> 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/30ffe7c3-39b5-43eb-a232-94fb8e5696de%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/4A35BBD1-EFD5-44F8-A418-C79D14B56283%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How do I create an image object from a remote image url

fugee ohu


On Tuesday, October 30, 2018 at 1:24:55 PM UTC-4, Walter Lee Davis wrote:

> On Oct 30, 2018, at 1:11 PM, fugee ohu <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="_gFJ4W7tBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">fuge...@...> wrote:
>
>
>
> On Tuesday, October 30, 2018 at 1:02:59 PM UTC-4, Walter Lee Davis wrote:
>
> > On Oct 30, 2018, at 12:09 PM, fugee ohu <[hidden email]> wrote:
> >
> >
> >
> > On Monday, October 29, 2018 at 11:28:58 PM UTC-4, Walter Lee Davis wrote:
> >
> > > On Oct 29, 2018, at 10:08 PM, fugee ohu <[hidden email]> wrote:
> > >
> > >
> > >
> > > On Monday, October 29, 2018 at 10:14:44 AM UTC-4, Colin Law wrote:
> > > On Mon, 29 Oct 2018 at 11:54, fugee ohu <[hidden email]> wrote:
> > >
> > >
> > > On Monday, October 29, 2018 at 4:48:42 AM UTC-4, Colin Law wrote:
> > > On Mon, 29 Oct 2018 at 05:08, fugee ohu <[hidden email]> wrote:
> > > How do I create an image object from a remote image url in rails console
> > >
> > > What do you mean by image object?
> > >
> > >
> > >  An object returned by Nokogiri as a result of selecting a css.("a") element containing  <img src="...">
> > >
> > > That doesn't make sense, you ask how to create an image object, then say that an image object is an object returned by nokogiri.  So to create it all you have to do is make that request to nokogiri.
> > >
> > > Colin
> > >
> > >
> > > I'm trying to insert an image into the assets table from web scraping Scraping gets me the src of the image I don't know if I should submit a form or do a raw insert in my script
> >
> > Read the documentation for your file upload package -- I believe you mentioned ActiveStorage -- about uploading from a URL. This is a common feature in many file attachment systems. CarrierWave, Shrine, CarrierWave, even Paperclip have a way to do this.
> >
> > It usually amounts to something like
> >
> > require 'open-uri'
> > file = open(remote_url).read
> > @your_instance.file = file
> > @your_instance.save # (the file should be persisted locally)
> >
> > Walter
> >
> > >
> > > --
> > > 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-ta...@googlegroups.com.
> > > To post to this group, send email to [hidden email].
> > > To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/9f8ba9af-0ad0-4fd0-856b-0f236c76149b%40googlegroups.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/9f8ba9af-0ad0-4fd0-856b-0f236c76149b%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/9f8ba9af-0ad0-4fd0-856b-0f236c76149b%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/9f8ba9af-0ad0-4fd0-856b-0f236c76149b%40googlegroups.com.
> > > For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.
> >
> >
> > Thanks, I'll use Carrierwave because when I googled "ActiveStorage remote file upload" what I found was a discussion where someone says you can't do this in ActiveStorage but you can with Carrierwave
> >  
> >
>
> I'd recommend Shrine. Much better documentation, current development, and a super-responsive development team.
>
> Walter
>
> > --
> > 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-ta...@googlegroups.com.
> > To post to this group, send email to [hidden email].
> > To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/2eebec62-614c-4d0e-9834-7c3a80bb4112%40googlegroups.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/2eebec62-614c-4d0e-9834-7c3a80bb4112%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/2eebec62-614c-4d0e-9834-7c3a80bb4112%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/2eebec62-614c-4d0e-9834-7c3a80bb4112%40googlegroups.com.
> > For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.
>
>
> With 'require open-uri' i can just use ActiveStorage don't need to use a gem?  
>

Open-URI is part of the Ruby standard library, not a third-party Gem. If you are in a Rails app, you won't need to do this, because it's part of the requirements. But if you are building a stand-alone script for testing, as you should, you may need to do this before the Kernel.open command will open a URI.

Walter

> --
> 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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="_gFJ4W7tBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="_gFJ4W7tBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
> To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/30ffe7c3-39b5-43eb-a232-94fb8e5696de%40googlegroups.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/30ffe7c3-39b5-43eb-a232-94fb8e5696de%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/30ffe7c3-39b5-43eb-a232-94fb8e5696de%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/30ffe7c3-39b5-43eb-a232-94fb8e5696de%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.


Doing everything in rails console so I can let the models do their job

--
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/955c9d6e-2406-4c9e-aa32-e25fbf4d89d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.