[Lift] Re: How to save the uploaded image into the folder via fileUpload in Lift?

2009-11-15 Thread Timothy Perrett
Neil, If you want to save the byte array, save it into the database, then just write a caching proxy that maps a URL to the dispatcher. That is, use SoftReferenceCache to cache the database read so that the next time the image is requested there is no database hit. This has been discussed a

[Lift] Re: How to save the uploaded image into the folder via fileUpload in Lift?

2009-11-15 Thread Neil.Lv
Tim, I'm not clear that how to do use the caching proxy and maps a URL to the dispatcher. I didn't find the archive about the SoftReferenceCache. Is there some exmaple that descript how to use is ~? :) Thanks very much! Cheers, Neil On Nov 15, 6:33 pm, Timothy Perrett

[Lift] Re: How to save the uploaded image into the folder via fileUpload in Lift?

2009-11-15 Thread Neil.Lv
It try to deploy the war to the tomcat5.5.25, and the path is different. Use LiftRules.getResource(/images/) to get this information: In the dev box: -- Path:Full(file:/G:/project/demo/src/main/webapp/images/ In the tomcat: -- Path:Full(jndi:/localhost/demo-1.0/images/ The

[Lift] Re: How to save the uploaded image into the folder via fileUpload in Lift?

2009-11-15 Thread Neil.Lv
Where is the images directory that should i create ? Out side of the webapp in the tomcat or in the webapps? like this: D:\tomcat_5.5.25\webapps\images And the lift how to know and find the images folder in the webapps of the tomcat, not the demo/src/main/webapp/images . Thanks

[Lift] Re: How to save the uploaded image into the folder via fileUpload in Lift?

2009-11-14 Thread Timothy Perrett
Neil, Try something like: var buff = new java.io.BufferedInputStream(input) try { var fos = new java.io.FileOutputStream(new File(/some/root/ filepath/ + image_hash_filename)) var in = 0 do { in = buff.read() if (in != -1){ fos.write(in) } } while((in != -1)) fos =

[Lift] Re: How to save the uploaded image into the folder via fileUpload in Lift?

2009-11-14 Thread Neil.Lv
It show this error message: ERROR - java.io.FileNotFoundException: \images\003.jpg # this is the code val receiptOk = fileHolder match { case Full(FileParamHolder(_, null, _, _)) = true case Full(FileParamHolder(_, mime, name, data)) if mime.startsWith(image/) = { var buff

[Lift] Re: How to save the uploaded image into the folder via fileUpload in Lift?

2009-11-14 Thread Timothy Perrett
Hmm, I guess you must be new to the JVM - you cant write a file inside a WAR file; it does not work like that. You'll need to write to a fully qualified path (as per my example). Cheers, tim On 14 Nov 2009, at 17:34, Neil.Lv wrote: It show this error message: ERROR -

[Lift] Re: How to save the uploaded image into the folder via fileUpload in Lift?

2009-11-14 Thread Neil.Lv
Tim, haha, yeah. I use this code to get the images folder(the full path) of the app. LiftRules.getResource(/images/).open_!.toString.substring(6) (The code is so redundant !) - G:\project\demo\src\main\webapp\images\ :) Thank you very much ! Cheers, Neil On Nov 15, 1:50 

[Lift] Re: How to save the uploaded image into the folder via fileUpload in Lift?

2009-11-14 Thread Timothy Perrett
I really, really would not use open_! - this is very dangerous. How about: LiftRules.getResource(/images/).map(_.substring(6)).openOr(/some/ default/path) Cheers, Tim On Nov 14, 6:25 pm, Neil.Lv anim...@gmail.com wrote: Tim,   haha, yeah.   I use this code to get the images folder(the

[Lift] Re: How to save the uploaded image into the folder via fileUpload in Lift?

2009-11-14 Thread David Pollak
On Sat, Nov 14, 2009 at 10:25 AM, Neil.Lv anim...@gmail.com wrote: Tim, haha, yeah. I use this code to get the images folder(the full path) of the app. LiftRules.getResource(/images/).open_!.toString.substring(6) (The code is so redundant !) -

[Lift] Re: How to save the uploaded image into the folder via fileUpload in Lift?

2009-11-14 Thread Neil.Lv
Hi all, Thanks for your tips, and I have some silly question about this. 1:) a directory that's not part of the app's exploded WAR file The direcotry tree like this, and Where is i can create a well defined directory that's not part of the app's exploded WAR file ? I'm not

[Lift] Re: How to save the uploaded image into the folder via fileUpload in Lift?

2009-11-14 Thread Neil.Lv
I want to save the images to a directory, because this images will be used in the flash params. This file path will be used in the javascript code . ### var imag=new Array(); imag[3]=/images/01.jpg; ### Cheers, Neil On Nov 15, 12:05 pm, Neil.Lv anim...@gmail.com wrote: Hi all,  

[Lift] Re: How to save the uploaded image into the folder via fileUpload in Lift?

2009-11-14 Thread Naftoli Gugenheim
The file not found error may be because the directory doesn't exist. Try calling file.mkdirs first. - Neil.Lvanim...@gmail.com wrote: I want to save the images to a directory, because this images will be used in the flash params. This file path will