How to find size of file?

W

Walter Huf

Hi, I'm the same one with the CGI download problem. This time, however, I
want to send the client the size of the file that will be downloaded. How
would I find the size of the file, so I can include that in the headers?

--Walter Huf--
(e-mail address removed)
http://hufman.cobalty.com
 
?

=?ISO-8859-1?Q?Gerhard_H=E4ring?=

Walter said:
Hi, I'm the same one with the CGI download problem. This time, however, I
want to send the client the size of the file that will be downloaded. How
would I find the size of the file, so I can include that in the headers?
567L

-- Gerhard
 
Y

Yermat

Walter Huf a écrit :
Hi, I'm the same one with the CGI download problem. This time, however, I
want to send the client the size of the file that will be downloaded. How
would I find the size of the file, so I can include that in the headers?

--Walter Huf--
(e-mail address removed)
http://hufman.cobalty.com

def sizeOf(f):
f.seek(0,2)
return f.tell()
 
I

Irmen de Jong

Yermat wrote:

def sizeOf(f):
f.seek(0,2)
return f.tell()

Hm. For better performance (and readability) try os.path.getsize(filename).....

--Irmen
 
?

=?ISO-8859-1?Q?I=F1igo?= Serna

Hi,

Other ways:
import os, stat
os.stat(filename)[stat.ST_SIZE]

Or better:

Best regards,
Iñigo Serna

El vie, 05-03-2004 a las 22:13, Walter Huf escribió:
Thank you!


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQBAScPqfN63/+cBjZoRAg/kAJ422p6BEUwf+V8VxYiY3IBCDucp7wCgw3v0
HU7YGWzVPR8SoBpweVVYSTc=
=LJwG
-----END PGP SIGNATURE-----
 

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,438
Messages
2,571,699
Members
48,796
Latest member
Greg L.
Top