X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 05F0A14B286B for ; Wed, 11 Aug 2004 22:41:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73772-05 for ; Thu, 12 Aug 2004 01:41:12 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id EBEB714B2867 for ; Wed, 11 Aug 2004 22:41:10 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i7C1fAiG076664 for ; Thu, 12 Aug 2004 01:41:10 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i7C1DMf7056077 for pgsql-php@postgresql.org; Thu, 12 Aug 2004 01:13:22 GMT From: ljb X-Newsgroups: comp.databases.postgresql.interfaces.php Subject: Re: blob size after pg_lo_open Date: Thu, 12 Aug 2004 01:13:21 +0000 (UTC) Organization: Hub.Org Networking Services Lines: 20 Message-ID: References: X-Complaints-To: usenet@news.hub.org User-Agent: slrn/0.9.8.0 (Linux) To: pgsql-php@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200408/19 X-Sequence-Number: 2907 TDyson@sybex.com wrote: > I have to store some files in a database and let users download the files. > I want to pull the file size so I can use the HTTP Content-length > header. I've tried using PHP's fstat to return the size, but I think the > object returned by pg_lo_open is not suitable. No, you can't use fstat() on a large object handle. If you really need the large object size, you have to open the large object with pg_lo_open(), seek to the end with pg_lo_seek($loid, 0, PGSQL_SEEK_END), and then get the position with pg_lo_tell($loid). This will return the number of bytes in the large object. But if you find yourself doing this a lot, you might be better off storing the file size (as calculated when uploaded) in another field in the database record. > Any ideas? BTW, I figured this was a pretty common need, but I could not > find a complete widget to deal with it. The best I could come up with was > complete apps, mostly image galleries, and a few code snippets. I've hardly ever bothered with Content-length. There is probably some advantage to using it but I don't know what it might be.