Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Simple Play 2.1 application that demonstrates how to stream an HTTP multipart request
Scala
branch: master

This branch is 22 commits ahead, 1 commit behind heiflo:master

Failed to load latest commit information.
app Removed unnecessary AWS S3 reference
conf initial commit
project Updated to Scala 2.10.1 and sbt 0.12.3
public Added stylesheet
test Unit tests pass now
.gitignore Enhanced .gitignore
README.md Updated docs

README.md

Streaming HTTP file upload demo for Play 2.1

This small demo shows how large files can be copied from client to a destination without requiring any temporary files, and only requires a minimal memory footprint. For example, FireFox sends 8KB chunks when uploading files, so only a few chunks would be held in memory for each client performing a transfer.

Large uploads, such as movies, should not be completely buffered by the Play app before copying the data to the destination. The Play 2.1 Iteratee examples for doing file upload do not explain how to use small in-memory buffers to stream an upload from the client to a destination.

This demo streams a File upload to a local file; you could easily modify this example to stream elsewhere, such as AWS S3 using the AWS Java SDK.

Just clone the repo and run it with Play on your local machine:

play debug run

You can upload using curl instead of the web browser. Thanks to Andrew Gaydenko for the incantation:

curl -i --no-keepalive -F name=myFile.mp4 -F filedata=@myFile.mp4 http://localhost:9000/upload

Files are uploaded to ~/uploadedFiles.

You'll find inline comments in the code.

Something went wrong with that request. Please try again.