Interface UploadRequest

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

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

    • fromPath

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

      static @NonNull UploadRequest fromPath(@NonNull Path path, @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

      static @NonNull UploadRequest fromBytes(@NonNull byte[] bytes, @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

      static @NonNull UploadRequest fromBytes(@NonNull byte[] bytes, @NonNull String key, @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.
    • fromInputStream

      static @NonNull UploadRequest fromInputStream(@NonNull InputStream inputStream, @NonNull String key)
      Creates an upload request backed by an input stream whose content length is unknown.
      Parameters:
      inputStream - the source input stream.
      key - the key under which the object will be stored (path/to/file).
      Returns:
      An UploadRequest from the given input stream and key.
      Since:
      3.1.0
    • fromInputStream

      static @NonNull UploadRequest fromInputStream(@NonNull InputStream inputStream, @NonNull String key, long contentLength)
      Creates an upload request backed by an input stream with a known content length. Providing the content length allows providers to stream the request without buffering and is required by some provider operations.
      Parameters:
      inputStream - the source input stream.
      key - the key under which the object will be stored (path/to/file).
      contentLength - the content length, in bytes.
      Returns:
      An UploadRequest from the given parameters.
      Since:
      3.1.0
    • fromInputStream

      static @NonNull UploadRequest fromInputStream(@NonNull InputStream inputStream, @NonNull String key, @Nullable String contentType, @Nullable Long contentLength)
      Creates an upload request backed by an input stream. Providing the content length allows providers to stream the request without buffering and is required by some provider operations.
      Parameters:
      inputStream - the source input stream.
      key - the key under which the object will be stored (path/to/file).
      contentType - the content type, or null when unknown.
      contentLength - the content length in bytes, or null when unknown.
      Returns:
      An UploadRequest from the given parameters.
      Since:
      3.1.0
    • fromCompletedFileUpload

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

      static @NonNull UploadRequest fromCompletedFileUpload(@NonNull io.micronaut.http.multipart.CompletedFileUpload completedFileUpload, @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

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

      static @NonNull UploadRequest fromStreamingFileUpload(@NonNull io.micronaut.http.multipart.StreamingFileUpload streamingFileUpload, @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 Optional<String> getContentType()
      Returns:
      the content type of this upload request.
    • getKey

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

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

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

      Callers must not access the stream while an upload is in progress. Provider implementations may close it, so callers that own the stream should ensure it is closed after a blocking upload returns or after a reactive upload terminates.

      Returns:
      an input stream of the object to be stored.
    • getMetadata

      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 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 String contentType)
      Parameters:
      contentType - the content type of this upload request.
      Since:
      1.1.0