Class ReactiveGridFsResource
java.lang.Object
org.springframework.data.mongodb.gridfs.ReactiveGridFsResource
- All Implemented Interfaces:
GridFsObject<Object,Publisher<DataBuffer>>
public class ReactiveGridFsResource
extends Object
implements GridFsObject<Object,Publisher<DataBuffer>>
- Since:
- 2.2
- Author:
- Mark Paluch, Christoph Strobl
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.mongodb.gridfs.GridFsObject
GridFsObject.Options -
Constructor Summary
ConstructorsConstructorDescriptionReactiveGridFsResource(Object id, String filename, GridFsObject.Options options, com.mongodb.reactivestreams.client.gridfs.GridFSDownloadPublisher downloadPublisher) Creates a new, absentReactiveGridFsResource.ReactiveGridFsResource(String filename, com.mongodb.reactivestreams.client.gridfs.GridFSDownloadPublisher downloadPublisher) Creates a new, absentReactiveGridFsResource. -
Method Summary
Modifier and TypeMethodDescriptionstatic ReactiveGridFsResourceObtain an absentReactiveGridFsResource.booleanexists()The actual file content.Obtain the download stream emitting chunks of data as they come in.getDownloadStream(int chunkSize) Obtain the download stream emitting chunks of data with givenchunkSizeas they come in.TheGridFSFile.getId()value converted into its simple java type.The filename.Mono<com.mongodb.client.gridfs.model.GridFSFile>Obtain the data asInputStream.Additional information like file metadata (eg. contentType).
-
Constructor Details
-
ReactiveGridFsResource
public ReactiveGridFsResource(String filename, @Nullable com.mongodb.reactivestreams.client.gridfs.GridFSDownloadPublisher downloadPublisher) Creates a new, absentReactiveGridFsResource.- Parameters:
filename- filename of the absent resource.downloadPublisher-
-
ReactiveGridFsResource
public ReactiveGridFsResource(@Nullable Object id, String filename, GridFsObject.Options options, @Nullable com.mongodb.reactivestreams.client.gridfs.GridFSDownloadPublisher downloadPublisher) Creates a new, absentReactiveGridFsResource.- Parameters:
id-filename- filename of the absent resource.options-downloadPublisher-- Since:
- 3.0
-
-
Method Details
-
absent
Obtain an absentReactiveGridFsResource.- Parameters:
filename- filename of the absent resource, must not be null.- Returns:
- never null.
- Since:
- 2.1
-
getFileId
Description copied from interface:GridFsObjectTheGridFSFile.getId()value converted into its simple java type.
ABsonStringwill be converted to plainString.- Specified by:
getFileIdin interfaceGridFsObject<Object,Publisher<DataBuffer>> - Returns:
- can be null depending on the implementation.
-
getFilename
Description copied from interface:GridFsObjectThe filename.- Specified by:
getFilenamein interfaceGridFsObject<Object,Publisher<DataBuffer>> - Returns:
- Throws:
IllegalStateException- See Also:
-
getGridFSFile
- Returns:
- the underlying
GridFSFile. Can be null if absent. - Since:
- 2.2
-
getInputStream
Obtain the data asInputStream.
NOTE: Buffers data in memory. UsegetDownloadStream()for large files.- Throws:
IllegalStateException- if the underlyingPublisherhas already been consumed.- Since:
- 3.0
- See Also:
-
getDownloadStream
Obtain the download stream emitting chunks of data as they come in.- Returns:
Flux.empty()if the file does not exist.- Throws:
IllegalStateException- if the underlyingPublisherhas already been consumed.- Since:
- 3.0
- See Also:
-
getContent
Description copied from interface:GridFsObjectThe actual file content.- Specified by:
getContentin interfaceGridFsObject<Object,Publisher<DataBuffer>> - Returns:
-
getOptions
Description copied from interface:GridFsObjectAdditional information like file metadata (eg. contentType).- Specified by:
getOptionsin interfaceGridFsObject<Object,Publisher<DataBuffer>> - Returns:
- never null.
-
getDownloadStream
Obtain the download stream emitting chunks of data with givenchunkSizeas they come in.- Parameters:
chunkSize- the preferred number of bytes per emittedDataBuffer.- Returns:
Flux.empty()if the file does not exist.- Throws:
IllegalStateException- if the underlyingPublisherhas already been consumed.- Since:
- 3.0
- See Also:
-
exists
public boolean exists()
-