pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedinput large object from internet
3+ messages / 3 participants
[nested] [flat]
* input large object from internet
@ 2000-09-19 02:20 S.A.Pamungkas <moenk_2000@yahoo.com>
2000-09-19 10:34 ` Re: input large object from internet Zeljko Trogrlic <zeljko@technologist.com>
0 siblings, 1 reply; 3+ messages in thread
From: S.A.Pamungkas @ 2000-09-19 02:20 UTC (permalink / raw)
To: pgsql-interfaces
Hi all
According imageviewer example, I made GUI ( by
applet-servlet ) for input data to DB, including blob.
Input data from localhost ( the same PC ) is ok. For
example, I could input image data by writing
"/usr/aji/home.gif" in my GUI.
My question : Is it possible to input blob from other
computer ( from ineternet ) ?
If YES, how to do that ? Which method should I use ?
This is my servlet skeleton code :
.............
String image_file = getImage_file(); // resulting
String "/usr/aji/home.gif"
.......
if(leccod!=null && teacod!=null && date!=null &&
viname!=null && image_file!=null && dept!=null)
{
Statement stat = null;
try
{
LargeObjectManager lom =
((org.postgresql.Connection)con).getLargeObjectAPI();
con.setAutoCommit(false);
byte buf[] = new byte[3000];
FileInputStream fis = new FileInputStream(new
File(image_file));
int oid = lom.create();
LargeObject blob = lom.open(oid);
int s, t=0;
while((s=fis.read(buf,0,buf.length))>0)
{
t += s;
blob.write(buf,0)
}
blob.close();
stat = con.createStatement();
stat.executeUpdate("insert into images values('" +
leccod + "','" + teacod + "','" + date + "','" +
viname + "'," + oid + ",'" + dept + "')");
con.commit();
con.setAutoCommit(false);
..........
Any suugestion would be appreciate.
Thank you.
-pamungkas-
__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: input large object from internet
2000-09-19 02:20 input large object from internet S.A.Pamungkas <moenk_2000@yahoo.com>
@ 2000-09-19 10:34 ` Zeljko Trogrlic <zeljko@technologist.com>
0 siblings, 0 replies; 3+ messages in thread
From: Zeljko Trogrlic @ 2000-09-19 10:34 UTC (permalink / raw)
To: S.A.Pamungkas <moenk_2000@yahoo.com>; pgsql-interfaces
>My question : Is it possible to input blob from other
>computer ( from ineternet ) ?
>If YES, how to do that ? Which method should I use ?
Check <INPUT type="FILE"> or something like that. You'll need file upload
servlet on server side, too.
^ permalink raw reply [nested|flat] 3+ messages in thread
* RE: input large object from internet
@ 2000-09-19 09:21 Peter Mount <petermount@maidstone.gov.uk>
0 siblings, 0 replies; 3+ messages in thread
From: Peter Mount @ 2000-09-19 09:21 UTC (permalink / raw)
To: 'S.A.Pamungkas' <moenk_2000@yahoo.com>; pgsql-interfaces
The fastpath & large object api's work over the same TCP/IP connection
(which you must be if you are using a servlet), so you can access blobs from
anywhere.
With the applet, you wont be able to access the user's local drive (part of
applet security), but you can using HTTP Post and standard HTML forms.
Peter
--
Peter Mount
Enterprise Support Officer, Maidstone Borough Council
Email: petermount@maidstone.gov.uk
WWW: http://www.maidstone.gov.uk
All views expressed within this email are not the views of Maidstone Borough
Council
-----Original Message-----
From: S.A.Pamungkas [mailto:moenk_2000@yahoo.com]
Sent: Tuesday, September 19, 2000 3:21 AM
To: pgsql-interfaces@postgresql.org
Subject: [INTERFACES] input large object from internet
Hi all
According imageviewer example, I made GUI ( by
applet-servlet ) for input data to DB, including blob.
Input data from localhost ( the same PC ) is ok. For
example, I could input image data by writing
"/usr/aji/home.gif" in my GUI.
My question : Is it possible to input blob from other
computer ( from ineternet ) ?
If YES, how to do that ? Which method should I use ?
This is my servlet skeleton code :
.............
String image_file = getImage_file(); // resulting
String "/usr/aji/home.gif"
.......
if(leccod!=null && teacod!=null && date!=null &&
viname!=null && image_file!=null && dept!=null)
{
Statement stat = null;
try
{
LargeObjectManager lom =
((org.postgresql.Connection)con).getLargeObjectAPI();
con.setAutoCommit(false);
byte buf[] = new byte[3000];
FileInputStream fis = new FileInputStream(new
File(image_file));
int oid = lom.create();
LargeObject blob = lom.open(oid);
int s, t=0;
while((s=fis.read(buf,0,buf.length))>0)
{
t += s;
blob.write(buf,0)
}
blob.close();
stat = con.createStatement();
stat.executeUpdate("insert into images values('" +
leccod + "','" + teacod + "','" + date + "','" +
viname + "'," + oid + ",'" + dept + "')");
con.commit();
con.setAutoCommit(false);
..........
Any suugestion would be appreciate.
Thank you.
-pamungkas-
__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2000-09-19 10:34 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-09-19 02:20 input large object from internet S.A.Pamungkas <moenk_2000@yahoo.com>
2000-09-19 10:34 ` Zeljko Trogrlic <zeljko@technologist.com>
2000-09-19 09:21 RE: input large object from internet Peter Mount <petermount@maidstone.gov.uk>
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