I am trying to stream large files to an endpoint. To briefly describe what this code does : - It generates a valid path, then stream the data to the disk, then store metadata.
It works well expect for one thing : The file seems to be stored in memory (as well as on the disk). My memory-free collectd metrics keeps going down... Also, it is worth mentioning that the server returns a 503 error even though the asynchronous process complete just fine. I could add an onError handler but it seems that the future completes OK. Do I need to cleanup something ? Is there something I am missing / doing wrong ? Any Idea ? I curl it like that : curl --form "videos=@81770ea1-6cde-4a61-a63c-d060970e0084.mkv" http://myserver/videos Thanks for the help! :) fileUpload("videos") { case (metadata, byteSource) => val cdnPath = s"${DateTime.now.year}/${DateTime.now.month}/${DateTime.now.day}" val mountPoint = resolveBestMountPoint() val baseDirectory = s"$mountPoint/$cdnPath/" new JavaFile(baseDirectory).mkdirs() val baseFilename: String = s"${UUID.randomUUID().toString}.${metadata.fileName.split("\\.").last}" val file: Path = Paths.get(mountPoint) resolve s"$cdnPath/$baseFilename" val futureCopyToDisk: Future[IOResult] = byteSource.runWith(FileIO.toPath(file)) val storeData: Future[(IOResult, Boolean)] = for { isCopied <- futureCopyToDisk isPersisted <- { val metaDataOverview = PersistMetadataOverview(s"/$cdnPath/$baseFilename", baseFilename, metadata.contentType, metadata.fileName, isCopied.count, mountPoint) metadataManager.persistMetadata(metaDataOverview) } } yield (isCopied, isPersisted) onSuccess(storeData) { (sum, isPersisted) => (sum.wasSuccessful, isPersisted) match { case (true, true) => logInfo(s"File successfully stored and persisted to ${file.toString}") complete(HttpResponse(StatusCodes.Created, headers = List(headerLocation(s"/videos/$baseFilename")))) case (true, false) => reject(UnableToPersistMetaDataToDataStore(file.toString)) case (false, true) => reject(UnableToPersistFileToDisk(file.toString)) case (false, false) => reject(UnableToPersistFileAndMetadataToDataStore(file.toString)) } } } -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.