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

**URL:** <https://www.ruby-forum.com/t/newby-question-check-image-size-before-getting-with-net-http/139079>\
**Category:** Ruby\
**Created:** [May 30, 2008, 4:54pm UTC](https://www.ruby-forum.com/t/newby-question-check-image-size-before-getting-with-net-http/139079 "2008-05-30T16:54:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ruchira\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8797f3/32.png) [@Ruchira\_B](https://www.ruby-forum.com/u/Ruchira_B)\
**Post date:** [May 30, 2008, 4:54pm UTC](https://www.ruby-forum.com/t/newby-question-check-image-size-before-getting-with-net-http/139079/1 "2008-05-30T16:54:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ruchira\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8797f3/32.png) [@Ruchira\_B](https://www.ruby-forum.com/u/Ruchira_B)\
**Post date:** [May 30, 2008, 6:04pm UTC](https://www.ruby-forum.com/t/newby-question-check-image-size-before-getting-with-net-http/139079/2 "2008-05-30T18:04:43Z")

</div>

Hi,

2008/5/30 Ruchira B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 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 H.

---

<div class="post-metadata">

**Author:** ![Ruchira\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8797f3/32.png) [@Ruchira\_B](https://www.ruby-forum.com/u/Ruchira_B)\
**Post date:** [May 30, 2008, 6:27pm UTC](https://www.ruby-forum.com/t/newby-question-check-image-size-before-getting-with-net-http/139079/3 "2008-05-30T18:27:41Z")

</div>

On May 30, 7:52 am, Heesob P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > (don’t know if Propfind would help and if it does how).
> 
> Park H.

Thank you very much Park.  
Ruchira
