pekko/akka-docs-dev/rst/scala/http/routing-dsl/directives/file-upload-directives/uploadedFile.rst
Johan Andrén 3c0877d964 +htt 16841 uploadedFile directive
Two new directives for accepting file uploads through multipart forms:

`uploadedFile` which allows for very simple upload into a temporary file
`fileUpload` which allows to simply work with the stream of bytes of an upload
2015-11-24 16:21:25 +01:00

31 lines
1.1 KiB
ReStructuredText

.. _-uploadedFile-:
uploadedFile
============
Signature
---------
.. includecode2:: /../../akka-http/src/main/scala/akka/http/scaladsl/server/directives/FileUploadDirectives.scala
:snippet: uploadedFile
Description
-----------
Streams the contents of a file uploaded as a multipart form into a temporary file on disk and provides the file and
metadata about the upload as extracted value.
If there is an error writing to disk the request will be failed with the thrown exception, if there is no field
with the given name the request will be rejected, if there are multiple file parts with the same name, the first
one will be used and the subsequent ones ignored.
.. note::
This directive will stream contents of the request into a file, however one can not start processing these
until the file has been written completely. For streaming APIs it is preferred to use the :ref:`-fileUpload-`
directive, as it allows for streaming handling of the incoming data bytes.
Example
-------
.. includecode2:: ../../../../code/docs/http/scaladsl/server/directives/FileUploadDirectivesExamplesSpec.scala
:snippet: uploadedFile