# FTP size incorrect for files \> 4GB

**URL:** <https://rubytalk.org/t/ftp-size-incorrect-for-files-4gb/41709>\
**Category:** ruby-talk\
**Created:** [27 October 2007 10:16 UTC](https://rubytalk.org/t/ftp-size-incorrect-for-files-4gb/41709 "2007-10-27T10:16:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raymond\_O\_Connor](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@Raymond\_O\_Connor](https://rubytalk.org/u/Raymond_O_Connor)\
**Post date:** [27 October 2007 10:16 UTC](https://rubytalk.org/t/ftp-size-incorrect-for-files-4gb/41709/1 "2007-10-27T10:16:36Z")

</div>

The net/ftp size method is supposed to return the size of a remote file,  
but when the size of the remote file is \> 4GB it seems to return the  
wrong size.

The size of the remote file I'm testing is about 4.5 GB and size()  
returns about 0.5 GB. Anyone having the same problems? Is there  
somewhere I can report this problem?

Thanks

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Jan\_Svitok](https://avatars.discourse-cdn.com/v4/letter/j/cab0a1/32.png) [@Jan\_Svitok](https://rubytalk.org/u/Jan_Svitok)\
**Post date:** [27 October 2007 18:57 UTC](https://rubytalk.org/t/ftp-size-incorrect-for-files-4gb/41709/2 "2007-10-27T18:57:38Z")

</div>

It works for me. Can you 1. post test code to reproduce, 2. specify  
ruby version and operating system?

You may try checking '12345678923456'.to\_i as to\_i is used to convert  
string response to integer.

Finally, try running the ftp command manually, to see the precise ftp  
server response. The code in net/ftp strips first three and the last  
character. Maybe your server responds in a slightly different format.

For more details see net/ftp source, It's pure ruby and easy to  
understand (at least the size method).

Jano

ruby -v:  
ruby 1.8.5 (2006-08-25) [i386-mswin32] (one-click, xp sp2)

require 'net/ftp'  
require 'test/unit'

class TestFtp \< Test::Unit::TestCase  
&nbsp;&nbsp;def setup  
&nbsp;&nbsp;&nbsp;&nbsp;@ftp = Net::FTP.new('ftp.tuwien.ac.at')  
&nbsp;&nbsp;&nbsp;&nbsp;@ftp.login  
&nbsp;&nbsp;&nbsp;&nbsp;@ftp.chdir('opsys/linux/Mandrake-iso/2008.0')  
&nbsp;&nbsp;end  
&nbsp;&nbsp;  
&nbsp;&nbsp;def test\_size  
&nbsp;&nbsp;&nbsp;&nbsp;assert\_equal 4612227072,  
@ftp.size('mandriva-linux-2008.0-free-dvd-x86\_64.iso')  
&nbsp;&nbsp;end  
&nbsp;&nbsp;  
&nbsp;&nbsp;def teardown  
&nbsp;&nbsp;&nbsp;&nbsp;@ftp.close  
&nbsp;&nbsp;end  
end

> **···**
>
> On 10/27/07, Raymond O'Connor \<nappin713@yahoo.com\> wrote:
> 
> > The net/ftp size method is supposed to return the size of a remote file,  
> > but when the size of the remote file is \> 4GB it seems to return the  
> > wrong size.
> > 
> > The size of the remote file I'm testing is about 4.5 GB and size()  
> > returns about 0.5 GB. Anyone having the same problems? Is there  
> > somewhere I can report this problem?

---

<div class="post-metadata">

**Author:** ![Tammo\_Tjarks](https://avatars.discourse-cdn.com/v4/letter/t/898d66/32.png) [@Tammo\_Tjarks](https://rubytalk.org/u/Tammo_Tjarks)\
**Post date:** [28 October 2007 13:40 UTC](https://rubytalk.org/t/ftp-size-incorrect-for-files-4gb/41709/3 "2007-10-28T13:40:04Z")

</div>

Hello,  
I am not sure, but coud it be that the OS has only 32bit? Normally then  
files bigger as $G should not be supported. But maybe also some of the  
help-programs only 32bit. Only a guess.

Raymond O'Connor wrote:

> **···**
>
> > The net/ftp size method is supposed to return the size of a remote file,  
> > but when the size of the remote file is \> 4GB it seems to return the  
> > wrong size.
> > 
> > The size of the remote file I'm testing is about 4.5 GB and size()  
> > returns about 0.5 GB. Anyone having the same problems? Is there  
> > somewhere I can report this problem?
> > 
> > Thanks

---

<div class="post-metadata">

**Author:** ![Raymond\_O\_Connor](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@Raymond\_O\_Connor](https://rubytalk.org/u/Raymond_O_Connor)\
**Post date:** [28 October 2007 00:22 UTC](https://rubytalk.org/t/ftp-size-incorrect-for-files-4gb/41709/4 "2007-10-28T00:22:16Z")

</div>

RE: Jano Svitok

Thanks for your help. I tried out size on the mandriva iso and it came  
out correctly, so I'm not sure what the problem is, but my guess at this  
point is something is set up oddly on the ftp server I connect to  
(Unfortunately its private so I can't post its information).

I did do calculations and for some reason on the ftp server I connect  
to, the size of files over 4 GB is reported as actual size - 4 GB.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Jan\_Svitok](https://avatars.discourse-cdn.com/v4/letter/j/cab0a1/32.png) [@Jan\_Svitok](https://rubytalk.org/u/Jan_Svitok)\
**Post date:** [28 October 2007 14:13 UTC](https://rubytalk.org/t/ftp-size-incorrect-for-files-4gb/41709/5 "2007-10-28T14:13:52Z")

</div>

You may try connecting manually, using a cmdline client. Then use  
CHDIR and SIZE commands to see what the server reports. The odds are  
that the server itself doesn't support files larger than 2^32  
(4294967296). The possible reasons are ftp software, the OS or used  
filesystem. Look up ftpd version, and search the internet for possible  
issues.

> **···**
>
> On 10/28/07, Raymond O'Connor \<nappin713@yahoo.com\> wrote:
> 
> > RE: Jano Svitok
> > 
> > Thanks for your help. I tried out size on the mandriva iso and it came  
> > out correctly, so I'm not sure what the problem is, but my guess at this  
> > point is something is set up oddly on the ftp server I connect to  
> > (Unfortunately its private so I can't post its information).
> > 
> > I did do calculations and for some reason on the ftp server I connect  
> > to, the size of files over 4 GB is reported as actual size - 4 GB.

---

<div class="post-metadata">

**Author:** ![Raymond\_O\_Connor](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@Raymond\_O\_Connor](https://rubytalk.org/u/Raymond_O_Connor)\
**Post date:** [30 October 2007 20:15 UTC](https://rubytalk.org/t/ftp-size-incorrect-for-files-4gb/41709/6 "2007-10-30T20:15:54Z")

</div>

Tammo and Jano thanks for the suggestions. The whole 32 bit  
architecture completely slipped my mind, and I'm sure it's the cause for  
the mess. Thanks again for the help!

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
