From: | "Mustafa Karakaplan" <mkarakaplan(at)inonu(dot)edu(dot)tr> |
---|---|
To: | pgsql-tr-genel(at)postgresql(dot)org |
Subject: | lo_read isleminde yardim |
Date: | 2007-02-01 09:10:26 |
Message-ID: | 20070201090859.M98680@inonu.edu.tr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-tr-genel |
Selamlar,
postgresql sunucudaki veri tabanina large obje olarak attigim jpg resimleri
clientin diskine resim.jpg olarak almak istiyorum.
asagidaki fonksiyon linux altinda sorunsuz calisiyor. Fakat windows icin
derledigimde (mingw ile) jpg resim duzgun gelmiyor. Internette arama yaptigimda
ayni problem var ama cozum bulamadim.
bu konuda yardimci olacak var mi acaba?
void exportFile(Oid lobjId)
{
int lobj_fd;
int nbytes, tmp,len;
int fd;
char buf[32768];
sprintf(q,"BEGIN");
db_sorgu();
lobj_fd = lo_open(conn, lobjId, INV_READ);
if (lobj_fd < 0)
{
fprintf(stderr,"can't open large object %d\n", lobjId);
}
#ifdef WINDOWS
fd = open("resim.jpg", "wb");
#else
fd = open("resim.jpg", O_CREAT|O_WRONLY, 0666);
#endif
if (fd < 0) {
fprintf(stderr, "can't open unix file filename");
}
len = lo_tell(conn,lobj_fd);
while ((nbytes = lo_read(conn, lobj_fd, buf, 32768)) > 0)
{
tmp = write(fd, buf, nbytes);
if (tmp < nbytes)
{
fprintf(stderr,"error while writing filename");
}
}
(void) lo_close(conn, lobj_fd);
(void) close(fd);
sprintf(q,"COMMIT");
db_sorgu();
return;
}
From | Date | Subject | |
---|---|---|---|
Next Message | Devrim GUNDUZ | 2007-02-01 18:12:18 | Re: lo_read isleminde yardim |
Previous Message | Eşref Atak | 2007-01-27 14:07:23 | Belgeler |