Created
June 26, 2014 14:27
-
-
Save fmpwizard/9ca8f08acfb6d7ad9aed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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