Обсуждение: Servlet uplad with Multipart and LO

Поиск
Список
Период
Сортировка

Servlet uplad with Multipart and LO

От
Dror Matalon
Дата:
Hi,

I'm using the com.oreilly.servlet library to handle multipart uploads
from a servlet.

Here is my understanding of the different options for storing the data
in the database.

1. Save the uploaded file in a file on the local file system and store
the meta data in the database.
Pros: Best performance, simple implementation
Cons: Separate module from the regular database stuff. Need to handle
permissions and storage issues.
2. Save the uploaded file in a bytea in the database.
Pros: Similar semantics to other data types. More simple than LO
Cons: Too slow
3. Save the uploaded file in a LO (Large Object).
Pros: Much faster than bytea,
Cons: Limited permissions. Anyone that has access to the database can
get to the LO. Slower than file storage.

I've decided to go with option 3, use Large Objects. Since in our, web
environment we provide a database to each developer we don't mind the
permissions limitations that Large Objects impose. We handle privileges
on the application level.


This seems like a very standard problem in a servlet/database
environment and yet I've looked quite a bit and searched the archives
and didn't find any discussions about this. Have I missed anything?


Dror


--
Dror Matalon
Zapatec Inc
1700 MLK Way
Berkeley, CA 94709
http://www.zapatec.com



Re: Servlet uplad with Multipart and LO

От
Toby Doig
Дата:
> 3. Save the uploaded file in a LO (Large Object).
> Pros: Much faster than bytea,
> Cons: Limited permissions. Anyone that has access to the database can
> get to the LO. Slower than file storage.

this is the approach I use because it has the added bonus of backing up
your data using replication. if you store everything in the database then
backing up the db backs up everything. also, if you give all your
webserver nodes access to teh db then there's no mucking about with files
etc. i understand there's a performance hit involved but the
administrative benefits are superb.

by the way, if performance is a real issue then you could store the file
in the db and cache a local copy of each web node. check the file mod date
before serving and then serve up the local copy. to introduce a new web
node just dump it in the cluster and it'll build up its own cache. when
disk space gets low just clear the cache. simple.

t