Interface UploadRequest
- All Known Implementing Classes:
AbstractUploadRequest,BytesUploadRequest,CompletedFileUploadRequest,FileUploadRequest
public interface UploadRequest
Object storage upload request.
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull UploadRequeststatic @NonNull UploadRequestfromBytes(@io.micronaut.core.annotation.NonNull byte[] bytes, @NonNull String key, @NonNull String contentType) static @NonNull UploadRequestfromCompletedFileUpload(@NonNull io.micronaut.http.multipart.CompletedFileUpload completedFileUpload) static @NonNull UploadRequestfromCompletedFileUpload(@NonNull io.micronaut.http.multipart.CompletedFileUpload completedFileUpload, @NonNull String key) static @NonNull UploadRequeststatic @NonNull UploadRequest@NonNull InputStream@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
@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
UploadRequestfrom 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
UploadRequestfrom 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
UploadRequestfrom the given parameters.
-
fromCompletedFileUpload
@NonNull static @NonNull UploadRequest fromCompletedFileUpload(@NonNull @NonNull io.micronaut.http.multipart.CompletedFileUpload completedFileUpload) - Parameters:
completedFileUpload- theCompletedFileUpload.- Returns:
- An
UploadRequestfrom the givenCompletedFileUpload.
-
fromCompletedFileUpload
@NonNull static @NonNull UploadRequest fromCompletedFileUpload(@NonNull @NonNull io.micronaut.http.multipart.CompletedFileUpload completedFileUpload, @NonNull @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.
-
getContentType
- Returns:
- the content type of this upload request.
-
getKey
- Returns:
- the file name with path.
-
getContentSize
- Returns:
- the size of the file, in bytes.
-
getInputStream
- Returns:
- an input stream of the object to be stored.
-
getMetadata
- Returns:
- a map with key-value pairs to be stored along the file. An empty map by default.
- Since:
- 1.1.0
-
setMetadata
- Parameters:
metadata- a map with key-value pairs to be stored along the file.- Since:
- 1.1.0
-
setContentType
- Parameters:
contentType- the content type of this upload request.- Since:
- 1.1.0
-