Re: blob size after pg_lo_open

Поиск
Список
Период
Сортировка
От ljb
Тема Re: blob size after pg_lo_open
Дата
Msg-id cfeg7h$1lt7$1@news.hub.org
обсуждение исходный текст
Ответ на blob size after pg_lo_open  (Thom Dyson <TDyson@sybex.com>)
Ответы Re: blob size after pg_lo_open
Список 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.

В списке pgsql-php по дате отправления:

Предыдущее
От: Justin Wyer
Дата:
Сообщение: Re: Strange session problem
Следующее
От: "Majolee InfoTech"
Дата:
Сообщение: Re: Strange session problem