Re: how to upload file (not into database)
Re: how to upload file (not into database)
- Subject: Re: how to upload file (not into database)
- From: Florijan Stamenkovic <email@hidden>
- Date: Thu, 14 Jul 2005 18:14:02 +0200
Standard file upload solutions imply storing uploaded file in database
as
blob. This makes batabesre rather huge.
Is there any possibility to store uploaded file in some directiory on
server
and to put into database only link to that file?
Of course. What I normally do is:
1. have a file upload that takes files either of a certain mime type or
extension.
2. take from my DatabaseInfo record the beginning of the directory path
where i stash that kind of file (ex:
/Volumes/MyMacVol/Users/flor385/DatabaseData/
3. finish the file path by getting the information from a record that
the file is related to
4. write the damn thing
5. try to save the editing context changes (so, the record if it is a
new on)
6. if all went well with saving be happy, if not delete the file
and it is easy to reconstruct the file path from the record afterwards
(the logic of which is handy to keep in your EO class of the record)
it is not all together difficult to do as you get your data, mime type
and filepath from the WOFileUpload component. what you need to look
into is the File class (java.io.File). key methods being
createNewFile() - or something like that, mkdirs() for creating
directories, exists() for checking etc etc. all together it is an easy,
handy class you can learn easily just by reading the JavaDoc for it.
thanks in advance
cheers
Flor
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden