Can this code get the path of app ?

  S.servletSession.open_!.getServletContext.getResourcePaths("/")

  But it doesn't work, and show this message.
    ->  value servletSession is not a member of object
net.liftweb.http.S

  What's the method can get this path string in the lift ?
  G:\project\demo\src\main\webapp\images
  ( To save the file into this path, G:\project\demo\src\main\webapp
\images\003.jpg )

Cheers,
  Neil

On Nov 15, 1:34 am, "Neil.Lv" <[email protected]> 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 <[email protected]> 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" <[email protected]> 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" <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to