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 am, Timothy Perrett <timo...@getintheloop.eu> wrote:
> 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 - 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 = new java.io.BufferedInputStream(new ByteArrayInputStream
> > (data))
> >    try {
> >     var fos = new java.io.FileOutputStream(new File("/images/" +
> > name))
> >     var in = 0
> >    do {
> >       in = buff.read()
> >       if (in != -1){
> >         fos.write(in)
> >       }
> >     } while((in != -1))
> >    fos = null
> >    in = 0
> >   } catch {
> >      case e => Log.error(e)
> >   } finally {
> >     buff.close()
> >   }
> >   buff = null
> >    true
> >  }
> > case Full(_) => {
> > S.error(S.??("invalid.receipt.attachment"))
> > false
> > }
> > case _ => true
> > }
>
> > #########
>
> >   Maybe this code is wrong ?
>
> >   new File("/images/" + name)
>
> >   I want to save it in the main\webapp\images\  folder.
> >     -> main\webapp\images\ 003.jpg
>
> >   :)
>
> > Cheers,
> >  Neil
>
> > On Nov 15, 12:23 am, Timothy Perrett <timo...@getintheloop.eu> wrote:
> >> 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 = null
> >>   in = 0} catch {
>
> >>   case e => Log.error(e)
>
> >> } finally {
> >>   buff.close()
> >> }
> >> buff = null
> >> }
>
> >> In my case, I had the data as an input stream - manipulate this code
> >> to take it however you need.
>
> >> Cheers, Tim
>
> >> On Nov 14, 7:55 am, "Neil.Lv" <anim...@gmail.com> wrote:
>
> >>>   Here is some code , but it's wrong!
>
> >>>   -->  java.io.FileNotFoundException: \images\1.jpeg
>
> >>>  if mime.startsWith("image/") => {
> >>>   try{
> >>>     var file: File  = new File("/images/1.jpeg");
> >>>     var fos:FileOutputStream = new FileOutputStream(file);
> >>>     fos.write(data)
> >>>   } catch {
> >>>     case e => println("exception:  " + e)
> >>>   }
> >>>   e.receipt(data).receiptMime(mime)
> >>>    true
> >>>  }
>
> >>>   I don't know how to write the code in the try catch statement.
>
> >>>   Does anyone can help  me ?~
>
> >>>   Thanks very much !
>
> >>> Cheers,
> >>>   Neil
>
> >>> On Nov 14, 1:58 pm, "Neil.Lv" <anim...@gmail.com> wrote:
>
> >>>> Hi all,
>
> >>>>    How to save the uploaded image into the folder via fileUpload in
> >>>> Lift?
>
> >>>>    I don't want to save it in the database, the example code in the
> >>>> Pocketchangeapp
>
> >>>> ###
> >>>>           val receiptOk = fileHolder match {
> >>>>             case Full(FileParamHolder(_, null, _, _)) => true
> >>>>             case Full(FileParamHolder(_, mime, _, data))
> >>>>                       if mime.startsWith("image/") => {
> >>>> //  How can i save the data into a image in the folder.
> >>>>                         e.receipt(data).receiptMime(mime)
> >>>>                         true
> >>>>                       }
> >>>>             case Full(_) => {
> >>>>               S.error("Invalid receipt attachment")
> >>>>               false
> >>>>             }
> >>>>             case _ => true
> >>>>           }
> >>>> ###
>
> >>>>    To save the image into the webapp\images folder, and it's shown
> >>>> just use this link:
> >>>>    /images/img1.jpg
>
> >>>>   Thanks for any suggestion!
>
> >>>> Cheers,
> >>>>   Neil
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to