Class FileUploadDirectives

Direct Known Subclasses:
FormFieldDirectives

public abstract class FileUploadDirectives extends FileAndResourceDirectives
  • Constructor Details

    • FileUploadDirectives

      public FileUploadDirectives()
  • Method Details

    • fileUpload

      public Route fileUpload(String fieldName, BiFunction<FileInfo,akka.stream.javadsl.Source<akka.util.ByteString,Object>,Route> inner)
      Collects each body part that is a multipart file as a tuple containing metadata and a Source for streaming the file contents somewhere. If there is no such field 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.
      Parameters:
      fieldName - (undocumented)
      inner - (undocumented)
      Returns:
      (undocumented)
    • fileUploadAll

      public Route fileUploadAll(String fieldName, Function<List<Map.Entry<FileInfo,akka.stream.javadsl.Source<akka.util.ByteString,Object>>>,Route> inner)
      Collects each body part that is a multipart file as a tuple containing metadata and a Source for streaming the file contents somewhere. If there is no such field the request will be rejected. Files are buffered into temporary files on disk so in-memory buffers don't overflow. The temporary files are cleaned up once materialized, or on exit if the stream is not consumed.
      Parameters:
      fieldName - (undocumented)
      inner - (undocumented)
      Returns:
      (undocumented)
    • storeUploadedFile

      public Route storeUploadedFile(String fieldName, Function<FileInfo,File> destFn, BiFunction<FileInfo,File,Route> inner)
      Streams the bytes of the file submitted using multipart with the given file name into a designated file on disk. If there is an error writing to disk the request will be failed with the thrown exception, if there is no such field 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.
      Parameters:
      fieldName - (undocumented)
      destFn - (undocumented)
      inner - (undocumented)
      Returns:
      (undocumented)
    • storeUploadedFiles

      public Route storeUploadedFiles(String fieldName, Function<FileInfo,File> destFn, Function<List<Map.Entry<FileInfo,File>>,Route> inner)
      Streams the bytes of the file submitted using multipart with the given field name into designated files on disk. If there is an error writing to disk the request will be failed with the thrown exception, if there is no such field the request will be rejected. Stored files are cleaned up on exit but not on failure.
      Parameters:
      fieldName - (undocumented)
      destFn - (undocumented)
      inner - (undocumented)
      Returns:
      (undocumented)