Skip to content

Instantly share code, notes, and snippets.

@fmpwizard
Created June 26, 2014 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmpwizard/9ca8f08acfb6d7ad9aed to your computer and use it in GitHub Desktop.
Save fmpwizard/9ca8f08acfb6d7ad9aed to your computer and use it in GitHub Desktop.
object OnDiskFileParamHolder {
def apply(n: String, mt: String, fn: String, inputStream: InputStream): OnDiskFileParamHolder =
{
val file: File = File.createTempFile("lift_mime", "upload")
val fos = new FileOutputStream(file)
val ba = new Array[Byte](8192)
def doUpload() {
inputStream.read(ba) match {
case x if x < 0 =>
case 0 => doUpload()
case x => fos.write(ba, 0, x); doUpload()
}
}
doUpload()
inputStream.close
fos.close
new OnDiskFileParamHolder(n, mt, fn, file)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment