Skip to content

Instantly share code, notes, and snippets.

@jkyamog
Created January 21, 2014 19:14
Show Gist options
  • Save jkyamog/8546327 to your computer and use it in GitHub Desktop.
Save jkyamog/8546327 to your computer and use it in GitHub Desktop.
def uploadFile(docId: String) = {
import scalax.io._
val output = Resource.fromFile("target/test-upload.txt")
output.write("hello world")(Codec.UTF8)
val testFile = new File("target/test-upload.txt")
val file = TemporaryFile(testFile)
val data = new MultipartFormData(Map(),
List(FilePart("test file", "test-upload.txt", Some("text/plain"), file)),
List.empty,
List.empty)
val insertResult = testController.uploadFile(docId)(FakeRequest(GET, "", FakeHeaders(), data))
contentAsString(insertResult)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment