HTTP problems on Windows?

P

Peter Bailey

Hi,
I'm working with a colleague over in Unixland in our company. I'm down
in Windowsland. He tells me that, using this same script below from
Unix, he can transmit PNG files properly to our target. I can't, though.
I don't get any error message. There's a pregnant pause when I run this
script, with a bunch of PNG files in my directory, but, when I go and
check the URL for the target, nothing's gone over. I've changed the
names to protect the innocent.

Does anyone know of any inherent problems with net/http under Windows?

Thanks.

require 'net/http'
require 'FileUtils'

host = "graphics-devl.mycompany.com"
port = 80

Dir.chdir("F:/workflows/graphics/png2orca/")

Dir.glob("*.png").each do |file|
image_contents = IO.read(file)
dir, file_name = File.split(file)

image_name = file_name.sub!(/\..*/, "")

Net::HTTP.start(host, port) do |http|
req = Net::HTTP::post.new("/image/loader/#{image_name}")

req.basic_auth 'username', 'password'

req.set_content_type("image/png")
req.body = image_contents
response = http.request(req)
end
FileUtils.rm(file)
end
 
J

John Joyce

Hi,
I'm working with a colleague over in Unixland in our company. I'm down
in Windowsland. He tells me that, using this same script below from
Unix, he can transmit PNG files properly to our target. I can't,
though.
I don't get any error message. There's a pregnant pause when I run
this
script, with a bunch of PNG files in my directory, but, when I go and
check the URL for the target, nothing's gone over. I've changed the
names to protect the innocent.

Does anyone know of any inherent problems with net/http under Windows?

Are you kidding?!! Uh, Windows would be the problem. It often is.
 
P

Peter Bailey

John said:
Are you kidding?!! Uh, Windows would be the problem. It often is.

Now, now. No need for religious wars. Personally, I'm planning on
getting a Mac at home. . . . But, yes, I've been a Windows guys for 15
years.
 
P

Peter Bailey

Peter said:
Now, now. No need for religious wars. Personally, I'm planning on
getting a Mac at home. . . . But, yes, I've been a Windows guys for 15
years.

Never mind. I found the problem, or, my Unix colleague did. Apparently,
Windows needs to be told to read a file either binarily or textually.
So, I had to modify this line to specifically tell it to read binarily.

image_contents = File.open(file, "rb").read()

Thanks.
Cheers.
 
J

John Joyce

I was just kidding. Too tempting.
If you're just moving some files, it shouldn't matter what kind they
are, but it should also be a bit simpler.
What about an ftp, or sftp instead of http?
Are those forward slashes ok in Windows? The pregnant pause could be
attempting to do something then timing out.
Also Unix uses permissions on directories. Do you have write
permissions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top