Interface UploadRequest
- All Known Implementing Classes:
AbstractUploadRequest, BytesUploadRequest, CompletedFileUploadRequest, FileUploadRequest, InputStreamUploadRequest, StreamingFileUploadRequest
public interface UploadRequest
Object storage upload request.
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull UploadRequeststatic @NonNull UploadRequeststatic @NonNull UploadRequestfromCompletedFileUpload(@NonNull io.micronaut.http.multipart.CompletedFileUpload completedFileUpload) static @NonNull UploadRequestfromCompletedFileUpload(@NonNull io.micronaut.http.multipart.CompletedFileUpload completedFileUpload, @NonNull String key) static @NonNull UploadRequestfromInputStream(@NonNull InputStream inputStream, @NonNull String key) Creates an upload request backed by an input stream whose content length is unknown.static @NonNull UploadRequestfromInputStream(@NonNull InputStream inputStream, @NonNull String key, long contentLength) Creates an upload request backed by an input stream with a known content length.static @NonNull UploadRequestfromInputStream(@NonNull InputStream inputStream, @NonNull String key, @Nullable String contentType, @Nullable Long contentLength) Creates an upload request backed by an input stream.static @NonNull UploadRequeststatic @NonNull UploadRequeststatic @NonNull UploadRequestfromStreamingFileUpload(@NonNull io.micronaut.http.multipart.StreamingFileUpload streamingFileUpload) static @NonNull UploadRequestfromStreamingFileUpload(@NonNull io.micronaut.http.multipart.StreamingFileUpload streamingFileUpload, @NonNull String key) @NonNull InputStreamReturns an input stream of the object to be stored.@NonNull StringgetKey()default voidsetContentType(@NonNull String contentType) default voidsetMetadata(@NonNull Map<String, String> metadata)
-
Method Details
-
fromPath
- Parameters:
path- the path to the file.- Returns:
- An
UploadRequestfrom the given path.
-
fromPath
- Parameters:
path- the path to the file.prefix- the prefix under which the file will be stored (prefix/fileName).- Returns:
- An
UploadRequestfrom the given path and prefix
-
fromBytes
- Parameters:
bytes- the source byte array.key- the key under which the file will be stored (path/to/file)- Returns:
- An
UploadRequestfrom 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
UploadRequestfrom 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
UploadRequestfrom 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
UploadRequestfrom 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, ornullwhen unknown.contentLength- the content length in bytes, ornullwhen unknown.- Returns:
- An
UploadRequestfrom the given parameters. - Since:
- 3.1.0
-
fromCompletedFileUpload
static @NonNull UploadRequest fromCompletedFileUpload(@NonNull io.micronaut.http.multipart.CompletedFileUpload completedFileUpload) - Parameters:
completedFileUpload- theCompletedFileUpload.- Returns:
- An
UploadRequestfrom the givenCompletedFileUpload.
-
fromCompletedFileUpload
static @NonNull UploadRequest fromCompletedFileUpload(@NonNull io.micronaut.http.multipart.CompletedFileUpload completedFileUpload, @NonNull String key) - Parameters:
completedFileUpload- theCompletedFileUpload.key- the key under which the file will be stored (path/to/file)- Returns:
- An
UploadRequestfrom the givenCompletedFileUploadand key.
-
fromStreamingFileUpload
static @NonNull UploadRequest fromStreamingFileUpload(@NonNull io.micronaut.http.multipart.StreamingFileUpload streamingFileUpload) - Parameters:
streamingFileUpload- theStreamingFileUpload.- Returns:
- An
UploadRequestfrom the givenStreamingFileUpload. - Since:
- 2.7.0
-
fromStreamingFileUpload
static @NonNull UploadRequest fromStreamingFileUpload(@NonNull io.micronaut.http.multipart.StreamingFileUpload streamingFileUpload, @NonNull String key) - Parameters:
streamingFileUpload- theStreamingFileUpload.key- the key under which the file will be stored (path/to/file)- Returns:
- An
UploadRequestfrom the givenStreamingFileUploadand key. - Since:
- 2.7.0
-
getContentType
-
getKey
@NonNull String getKey()- Returns:
- the file name with path.
-
getContentSize
-
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
-
setMetadata
-
setContentType
- Parameters:
contentType- the content type of this upload request.- Since:
- 1.1.0
-