pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
blob size after pg_lo_open
3+ messages / 2 participants
[nested] [flat]

* blob size after pg_lo_open
@ 2004-08-11 20:57  Thom Dyson <TDyson@sybex.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Thom Dyson @ 2004-08-11 20:57 UTC (permalink / raw)
  To: pgsql-php

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.

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.


Thom Dyson
Director of Information Services
Sybex, Inc.
 




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: blob size after pg_lo_open
@ 2004-08-12 01:13  ljb <ljb220@mindspring.com>
  parent: Thom Dyson <TDyson@sybex.com>
  0 siblings, 1 reply; 3+ messages in thread

From: ljb @ 2004-08-12 01:13 UTC (permalink / raw)
  To: pgsql-php

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.



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: blob size after pg_lo_open
@ 2004-08-12 14:35  Thom Dyson <TDyson@sybex.com>
  parent: ljb <ljb220@mindspring.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Thom Dyson @ 2004-08-12 14:35 UTC (permalink / raw)
  To: pgsql-php





Thanks.  Glad I wasn't missing anything obvious.

I need content length so that browsers get a progress meter.  Working on an
application to sell downloads around 2 - 4 Mb.

Thom Dyson
Director of Information Services
Sybex, Inc.



pgsql-php-owner@postgresql.org wrote on 08/11/2004 06:13:21 PM:

> TDyson@sybex.com wrote:
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.

> 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.





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2004-08-12 14:35 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-08-11 20:57 blob size after pg_lo_open Thom Dyson <TDyson@sybex.com>
2004-08-12 01:13 ` ljb <ljb220@mindspring.com>
2004-08-12 14:35   ` Thom Dyson <TDyson@sybex.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox