Newby Question: Check image size before getting with Net::Http

R

Ruchira Bomiriya

Dear Expert,

I want to check the file size of a URI to identify large files (I will
decide on threshold) without having to get the whole file first.

Can I get just the file size using something related to Net::Http
(don't know if Propfind would help and if it does how).

Thanks in advance.
Ruchira
 
H

Heesob Park

Hi,

2008/5/30 Ruchira Bomiriya said:
Dear Expert,

I want to check the file size of a URI to identify large files (I will
decide on threshold) without having to get the whole file first.

Can I get just the file size using something related to Net::Http
(don't know if Propfind would help and if it does how).

require 'net/http'

response = nil
Net::HTTP.start('www.biostat.wisc.edu', 80) {|http|
response = http.head('/bcg/categories/languages/ruby/ruby_logo.png')
}
p response['content-length']



Regards,

Park Heesob
 
R

Ruchira Bomiriya

Hi,

2008/5/30 Ruchira Bomiriya said:
Dear Expert,
I want to check the file size of a URI to identify large files (I will
decide on threshold) without having to get the whole file first.
Can I get just the file size using something related to Net::Http
(don't know if Propfind would help and if it does how).

require 'net/http'

response = nil
Net::HTTP.start('www.biostat.wisc.edu', 80) {|http|
response = http.head('/bcg/categories/languages/ruby/ruby_logo.png')
}
p response['content-length']

Regards,

Park Heesob

Thank you very much Park.
Ruchira
 

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
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top