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

Discussion in 'Ruby' started by Ruchira Bomiriya, May 30, 2008.

  1. 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
     
    Ruchira Bomiriya, May 30, 2008
    #1
    1. Advertising

  2. Ruchira Bomiriya

    Heesob Park Guest

    Hi,

    2008/5/30 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).
    >


    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
     
    Heesob Park, May 30, 2008
    #2
    1. Advertising

  3. On May 30, 7:52 am, Heesob Park <> wrote:
    > Hi,
    >
    > 2008/5/30 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).

    >
    > 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
     
    Ruchira Bomiriya, May 30, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nicholas

    check file size before post

    nicholas, Oct 13, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    5,021
    Sayed Hashimi
    Oct 13, 2004
  2. insomniux
    Replies:
    4
    Views:
    372
    Victor Bazarov
    Mar 16, 2006
  3. vsoler
    Replies:
    4
    Views:
    260
    Steve Holden
    Feb 1, 2009
  4. vsoler
    Replies:
    3
    Views:
    262
    John Machin
    Feb 2, 2009
  5. Filip De Backer

    Check if image file exists before linking to Image object

    Filip De Backer, Jun 11, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    314
    Filip De Backer
    Jun 11, 2004
Loading...

Share This Page