Questions tagged [open-uri]

OpenURI is a Ruby module included in the standard library, which provides an easy-to-use wrapper for net/http, net/https and net/ftp.

311 questions
0
votes
1 answer

How to tell when Ruby's OpenURI open() function gives a 404 page not found error?

I want to grab the contents of a webpage like this: open("http://www.ruby-lang.org/") However, sometimes, that page doesn't exist: open("http://www.ruby-lang.org/blabla.html") The open command throws an exception. I know I can catch that…
at.
  • 50,922
  • 104
  • 292
  • 461
0
votes
1 answer

open uri on jruby proxy issues localhost

I was originally using rsolr to generate and connect to solr cores on my local machine. This all worked fine in ruby until we moved to jruby. I now receive a 504 gateway error for localhost http requests. This comes from Open-uri. We do have a…
damau
  • 334
  • 4
  • 9
0
votes
2 answers

Include both single and multiple text strings with Regex (in Ruby)?

so I have this problem where I am to list every country in a list in Excel by using Open-URI. Everything is working properly but I can't seem to figure how to get my RegExp-"string" to include single-named countries (like "Sweden") but also…
Fjurg
  • 487
  • 3
  • 10
0
votes
4 answers

How to read an xlsx or xls file from a URL

I'm trying to open a file from a URL using roo (1.11.0) Foobazs-iMac:pipeline foobazlabs$ irb irb(main):001:0> require 'roo' require '=> true irb(main):002:0> require 'open-uri' => true irb(main):003:0>…
Robin Rosicky
  • 325
  • 4
  • 9
0
votes
1 answer

Infinite recursion with Paperclip remote image uploading

After successfully implementing the code from Trevor Turk's blogpost "Easy Upload via URL with Paperclip" several times already, in this latest iteration my app gives me the following error: Started POST "/pins" for 127.0.0.1 at 2013-02-22 14:05:20…
0
votes
1 answer

Post Audio to Soundcloud from S3 bucket?

I've successfully followed Soundcloud's API documentation but hit an error that's got me stuck. When uploading / posting a file using their example I have no trouble when I hard code a file on my local machine. What I really want to do is transfer…
Raoot
  • 1,751
  • 1
  • 25
  • 51
0
votes
1 answer

How can I block this code with Net::HTTP in ruby?

Here is a URL http://192.168.1.2:1218/?name=verify_code_string_queue&opt=get&auth=verify_code_string_queue It will return a string or a status code like SQS_GET_END Now I need to break the loop when the url return a string,or keep blocking. Here is…
ZhuRong
  • 1
  • 2
0
votes
2 answers

How to mock Kernel.open or open-uri without calling Kernel explicitly?

How to mock this call in RSpec? require 'open-uri' class FileFoo < ActiveRecord::Base def download image_url open("tmp/#{file}", 'wb') do |file| file << open(image_url).read end end end Tried mocking FileFoo.open, but this did not…
B Seven
  • 44,484
  • 66
  • 240
  • 385
0
votes
1 answer

RSS parsing error on Heroku

I'm doing some simple RSS parsing and rendering - works perfectly fine on localhost and production at Heroku, but for some reason this particular RSS feed works only on localhost, but not when deployed at Heroku. Here is the RSS…
cman77
  • 1,753
  • 1
  • 22
  • 48
0
votes
1 answer

Rails - Access file sitting in different port

I have two instances of web server. One is running on port 3000 and one is running on 9090. I want to access the JSON file sitting in the 9090 port. In the rails model, I'm able to access the JSON file fine when I use stream =…
Ji Mun
  • 1,800
  • 4
  • 18
  • 27
0
votes
2 answers

button to save current page in rails 3.2

I need to have a button to save the current web site (just like clicking on "Save as"), I created a method in the controller which works great for any external site (like http://www.google.com) but doesn't work for the sites inside my application, I…
Andres Calle
  • 257
  • 1
  • 3
  • 11
0
votes
2 answers

No such file or directory: open-uri in rails controller

I am trying to use open method of open-uri gem in Rails. When I try it in standalone Ruby application I just require it on top of the file and everything is ok. But now I want it to use it controller in Rails app. Is it advisable to put require on…
Иван Бишевац
  • 13,811
  • 21
  • 66
  • 93
0
votes
1 answer

Ruby openuri test if uri is valid

I'm trying to test if a uri is valid (e.g. actually has content, not testing if it is well formed here) using ruby code, and I can open a uri using open(uri). But in my case, the uri is a link to a file to be downloaded and I don't want to have to…
Jeff Storey
  • 56,312
  • 72
  • 233
  • 406
0
votes
1 answer

send Mail in ruby on rails with attachment of one image, which from google-Chart-API

Here after called the controller.rb, one file(chart.png) will save in my rails app folder, so how to take this and will attach with mail? controller.rb def mail @imageURL =…
amtest
  • 690
  • 1
  • 6
  • 26
0
votes
1 answer

Ruby on Rails open URI issue with broken file source

I am having a hell of a problem here. I'm using ruby on rails: ruby 1.8.7 (2011-12-10 patchlevel 356) rails 2.3.14 I'm trying a simple open with open-uri on the following address: http://jollymag.net/n/10390-летни-секс-пози-във-водата.html (link is…
1 2 3
20
21