OK, so what persistence type are you using? Mapper or JPA?
If you plan to upload large files you will need to use the streaming
API by adding the following in Boot.scala
LiftRules.handleMimeFile = (fieldName, contentType, fileName,
inputStream) =>
OnDiskFileParamHolder(fieldName, contentType, fileName,
inputStream)
Once you have your images in the database, you will also have to
stream them back out and I would recommend implementing a cache to do
so (we have SoftReferenceCache that is thread safe in the lift-util
package).
As for uploading to S3, you will of course have to upload the file
first to the webserver (lift app) then asynchronously push that to S3.
Perhaps checkout JetS3t ( http://to.ly/jHm ) - you could do something
neat with actors here to keep the UI smooth / slick.
If you look at the JetS3t docs you'll see its possible to sent byte
array data, which you can get from your FileParamHolder like so:
theUpload.is.map(v => v.file).openOr(Array())
You'll have to figure out how all this is going to fit together for
your specific circumstances, but you should be getting the general
idea.
HTH
Cheers, Tim
On Jul 13, 7:24 pm, kjetilge <[email protected]> wrote:
> Thanks, I've now taken the upload part of the code and integrated it
> in to my learning project. I can now choose a file for upload, the
> file is uploaded but not stored, after the upload is complete the page
> displays the file details. Very good :-)
> I'm planning to build a video training site. I will need to upload
> images and video.
>
> I think perhaps it's a good idea to keep the images in the database
> and the video as a file. I have a similar site developed in rails
> (www.fagfilm.no- no that's not what you think it is...) that stores
> the video on Amazoon S3. So actually i'd like to be able to upload the
> video to S3.
>
> On Jul 13, 6:12 pm, Timothy Perrett <[email protected]> wrote:
>
>
>
> > Hi there again,
>
> > Please keep discussions strictly on list - its the only way for everyone to
> > benefit from the conversation we have and interject where they feel they
> > want to. This means you get more input from more sources and doesn't mail
> > people directly (my personal preference).
>
> > If your interested in how one uploads a file in Lift, checkout the sample
> > application here:http://to.ly/jtz
>
> > Do you have any experience of developing with Java? Which would you rather,
> > save to database, or save to file? The impl is quite different for each.
>
> > Cheers, Tim
>
> > > On 13/07/2009 16:20, "kjetilge" <[email protected]> wrote:
> > > Thanks. Well, it helps, I've learned something new, but what would
> > > really be useful is a link or two to sample code showing how this is
> > > done in real life. I've just recently finished reading Programming in
> > > Scala and most of the Lift Book and I cant remember anything from this
> > > text that would directly help me with persisting an Array[Byte] to a
> > > database or as a file.
>
> > > I guess I could use Scala.io or java.io for saving files perhaps ? But
> > > WHERE should the files go ? I come from Rails where finding out these
> > > things cost 30 sec googling. I must say that finding relevant
> > > tutorials and (working) sample code for basic tasks in Lift is very
> > > hard, even for a determined wannabe Lift developer like myself :-)
>
> > > On 13/07/2009 14:39, "Timothy Perrett" <[email protected]> wrote:
>
> > > Hi there,
>
> > > Generally speaking, that's now how uploading in lift works - any given
> > > upload
> > > goes into a FileParamHolder object then you can persist it however you
> > > would
> > > like (filesystem, database etc) as your essentially left with
> > > Array[Byte]...
>
> > > Does that help?
>
> > > Cheers, Tim
>
> > > On 13/07/2009 14:26, "kjetilge" <[email protected]> wrote:
>
> > >> I'm a newbie and I'm having troble with finding a hint in the Liftbook
> > >> on how to set the path for an upload folder in Lift. In the manual
> > >> there is an example using a variable called tmpDir. Problem is, there
> > >> is no explanation for what the value of this variable should be. Apart
> > >> from that, I've at least managed to load an image in the browser after
> > >> defining a pictures folder in main/resources/toserve/pictures by
> > >> using:
> > >> ResourceServer.allow {
> > >> case "pictures" :: _ => true
> > >> }
> > >> Then I can do: <img src="/classpath/pictures/sykkel.jpg" alt="Sykkel"/
> > >>> , and it works :-)
> > >> But when I set the value tmpDir="/classpath/pictures/" and try to
> > >> upload a file I get:
> > >> java.io.FileNotFoundException: /classpath/pictures/Lift Book.pdf
>
> > >> I'm obviously doing something terribly wrong. Does anybody know how to
> > >> do this ?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---