Interface UploadRequest

All Known Implementing Classes:
AbstractUploadRequest, BytesUploadRequest, CompletedFileUploadRequest, FileUploadRequest, StreamingFileUploadRequest

public interface UploadRequest
Object storage upload request.
Since:
1.0.0
  • Method Details

    • fromPath

      @NonNull static @NonNull UploadRequest fromPath(@NonNull @NonNull Path path)
      Parameters:
      path - the path to the file.
      Returns:
      An UploadRequest from the given path.
    • fromPath

      @NonNull static @NonNull UploadRequest fromPath(@NonNull @NonNull Path path, @NonNull @NonNull String prefix)
      Parameters:
      path - the path to the file.
      prefix - the prefix under which the file will be stored (prefix/fileName).
      Returns:
      An UploadRequest from the given path and prefix
    • fromBytes

      @NonNull static @NonNull UploadRequest fromBytes(@NonNull @io.micronaut.core.annotation.NonNull byte[] bytes, @NonNull @NonNull String key)
      Parameters:
      bytes - the source byte array.
      key - the key under which the file will be stored (path/to/file)
      Returns:
      An UploadRequest from the given byte array and key
    • fromBytes

      @NonNull static @NonNull UploadRequest fromBytes(@NonNull @io.micronaut.core.annotation.NonNull byte[] bytes, @NonNull @NonNull String key, @NonNull @NonNull String contentType)
      Parameters:
      bytes - the source byte array.
      key - the key under which the file will be stored (path/to/file)
      contentType - the content type of the file to store.
      Returns:
      An UploadRequest from the given parameters.
    • fromCompletedFileUpload

      @NonNull static @NonNull UploadRequest fromCompletedFileUpload(@NonNull @NonNull io.micronaut.http.multipart.CompletedFileUpload completedFileUpload)
      Parameters:
      completedFileUpload - the CompletedFileUpload.
      Returns:
      An UploadRequest from the given CompletedFileUpload.
    • fromCompletedFileUpload

      @NonNull static @NonNull UploadRequest fromCompletedFileUpload(@NonNull @NonNull io.micronaut.http.multipart.CompletedFileUpload completedFileUpload, @NonNull @NonNull String key)
      Parameters:
      completedFileUpload - the CompletedFileUpload.
      key - the key under which the file will be stored (path/to/file)
      Returns:
      An UploadRequest from the given CompletedFileUpload and key.
    • fromStreamingFileUpload

      @NonNull static @NonNull UploadRequest fromStreamingFileUpload(@NonNull @NonNull io.micronaut.http.multipart.StreamingFileUpload streamingFileUpload)
      Parameters:
      streamingFileUpload - the StreamingFileUpload.
      Returns:
      An UploadRequest from the given StreamingFileUpload.
      Since:
      2.7.0
    • fromStreamingFileUpload

      @NonNull static @NonNull UploadRequest fromStreamingFileUpload(@NonNull @NonNull io.micronaut.http.multipart.StreamingFileUpload streamingFileUpload, @NonNull @NonNull String key)
      Parameters:
      streamingFileUpload - the StreamingFileUpload.
      key - the key under which the file will be stored (path/to/file)
      Returns:
      An UploadRequest from the given StreamingFileUpload and key.
      Since:
      2.7.0
    • getContentType

      @NonNull @NonNull Optional<String> getContentType()
      Returns:
      the content type of this upload request.
    • getKey

      @NonNull @NonNull String getKey()
      Returns:
      the file name with path.
    • getContentSize

      @NonNull @NonNull Optional<Long> getContentSize()
      Returns:
      the size of the file, in bytes.
    • getInputStream

      @NonNull @NonNull InputStream getInputStream()
      Returns:
      an input stream of the object to be stored.
    • getMetadata

      @NonNull default @NonNull Map<String,String> getMetadata()
      Returns:
      a map with key-value pairs to be stored along the file. An empty map by default.
      Since:
      1.1.0
    • setMetadata

      default void setMetadata(@NonNull @NonNull Map<String,String> metadata)
      Parameters:
      metadata - a map with key-value pairs to be stored along the file.
      Since:
      1.1.0
    • setContentType

      default void setContentType(@NonNull @NonNull String contentType)
      Parameters:
      contentType - the content type of this upload request.
      Since:
      1.1.0