Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I need to verify whether some files are correctly uploaded to a remote server. I have the file info such as file size and file checksums in the database. May I know how can I get the file size of a file in a remote server in perl. Any perl modules that has this capability?

Thanks,
Peter
  • Comment on Verify file is there in a remote server

Replies are listed 'Best First'.
Re: Verify file is there in a remote server
by ikegami (Patriarch) on Apr 01, 2010 at 01:41 UTC

    What kind of server?

    One would presume that whatever protocol you used to upload the file has a function to retrieve information about the file too. Then again, I shouldn't make assumptions about a protocol that doesn't even let you if a transfer was successful or not.

      I am using a custom made file protcol to upload files, but I can use http to retrieve the file info.

        The easiest and simplest way, since you only have http access to those files.

        Write a script and put it there with the files, then you can call that script with file name as a param e.g: getsize.pl?file=somefile.zip.

        It will then return the filesize or checksum or both (it's up to you to decide). And you can use LWP to fetch the response automatically

        If the file is web accessible, you could probably do a HEAD request to fetch its size. Or better yet, return the information you want in the response to your upload request.