Re: error inserting big files in DB.

From: Richard Huxton <dev(at)archonet(dot)com>
To: Marlos Corrêa <listastec(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: error inserting big files in DB.
Date: 2005-08-15 16:24:30
Message-ID: 4300C1BE.8040305@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Marlos Corrêa wrote:
> Hi, Folks.
>
> I've a problem so i can use some help.
> I've trying to put a 5 MB file in my database, but i got an error.
> Anyone knows if "lo_import" or "lo" (type of bytea) has a limit of
> data transferred in one operation?

There are two things here - large-objects (accessed by the lo_xxx
functions) and bytea - which are just a standard data-type.

> Some people tell me that i can't transferr more than 1 MB a time to
> Postgresql, so i need to

Which people? Did they quote the manuals?

> divide my file in many small pices, than upload they one at time, and
> finally, use some workaround in DB to restore my original file. Is
> this correct?

Not as far as I have heard. Did you try the manuals?

> Below is a piece of code that i use:
>
> $conteudo=addslashes(fread(fopen($arq, "r"), filesize($arq)));
> $sql="insert into arquivos (nome, tipo, tamanho, dados) values
> ('$arq_name', '$arq_type', '$arq_size', lo_import('" .
> addslashes($arq) . "'));";
>
> I would be pleased if anyone could help me.

You said you got an error, but don't actually say what error it was.
Come to think of it, you don't say what language that code fragment is
in - presumably PHP since you have "addslashes()" mentioned. What was
the error?

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-08-15 16:53:25 Re: Question about the NAME type used in pg_proc and pg_class
Previous Message Sven Willenberger 2005-08-15 16:12:15 Re: Serial Unique question