Class InputStreamUploadRequest
- All Implemented Interfaces:
UploadRequest
UploadRequest backed by an InputStream.
The request returns the same stream instance and does not copy or buffer its contents. Callers must not access the stream while an upload is in progress. Provider implementations may close the stream, so callers that own it should ensure it is closed after a blocking upload returns or after a reactive upload terminates.
Because the stream is not recreated, automatic retries may require a stream that supports
InputStream.mark(int) and InputStream.reset(). A non-repeatable stream may fail if a
provider retries after consuming part of it. Providing the content length allows providers to
stream the request without buffering and is required by some provider operations.
- Since:
- 3.1.0
-
Field Summary
Fields inherited from class AbstractUploadRequest
contentType, metadata -
Constructor Summary
ConstructorsConstructorDescriptionInputStreamUploadRequest(@NonNull InputStream inputStream, @NonNull String key) Creates a request with an unknown content length and a content type inferred from the key.InputStreamUploadRequest(@NonNull InputStream inputStream, @NonNull String key, long contentLength) Creates a request with a known content length and a content type inferred from the key.InputStreamUploadRequest(@NonNull InputStream inputStream, @NonNull String key, @Nullable String contentType, @Nullable Long contentLength) Creates a request with optional content type and content length.InputStreamUploadRequest(@NonNull InputStream inputStream, @NonNull String key, @Nullable String contentType, @Nullable Long contentLength, @NonNull Map<String, String> metadata) Creates a request with optional content type, optional content length, and metadata. -
Method Summary
Modifier and TypeMethodDescription@NonNull InputStreamReturns an input stream of the object to be stored.@NonNull StringgetKey()Methods inherited from class AbstractUploadRequest
getMetadata, setContentType, setMetadata
-
Constructor Details
-
InputStreamUploadRequest
Creates a request with an unknown content length and a content type inferred from the key.- Parameters:
inputStream- the source input stream.key- the key under which the object will be stored.- Since:
- 3.1.0
-
InputStreamUploadRequest
public InputStreamUploadRequest(@NonNull InputStream inputStream, @NonNull String key, long contentLength) Creates a request with a known content length and a content type inferred from the key.- Parameters:
inputStream- the source input stream.key- the key under which the object will be stored.contentLength- the number of bytes to read from the stream.- Since:
- 3.1.0
-
InputStreamUploadRequest
public InputStreamUploadRequest(@NonNull InputStream inputStream, @NonNull String key, @Nullable String contentType, @Nullable Long contentLength) Creates a request with optional content type and content length.- Parameters:
inputStream- the source input stream.key- the key under which the object will be stored.contentType- the content type, ornullwhen unknown.contentLength- the number of bytes to read from the stream, ornullwhen unknown.- Since:
- 3.1.0
-
InputStreamUploadRequest
public InputStreamUploadRequest(@NonNull InputStream inputStream, @NonNull String key, @Nullable String contentType, @Nullable Long contentLength, @NonNull Map<String, String> metadata) Creates a request with optional content type, optional content length, and metadata.- Parameters:
inputStream- the source input stream.key- the key under which the object will be stored.contentType- the content type, ornullwhen unknown.contentLength- the number of bytes to read from the stream, ornullwhen unknown.metadata- key-value pairs to store with the object.- Since:
- 3.1.0
-
-
Method Details
-
getContentType
-
getKey
- Returns:
- the file name with path.
-
getContentSize
-
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.
-