Class ReactiveGridFsTemplate
java.lang.Object
org.springframework.data.mongodb.gridfs.ReactiveGridFsTemplate
- All Implemented Interfaces:
- ReactiveGridFsOperations
ReactiveGridFsOperations implementation to store content into MongoDB GridFS. Uses by default
 DefaultDataBufferFactory to create buffers.- Since:
- 2.2
- Author:
- Mark Paluch, Nick Stolwijk, Denis Zavedeev, Christoph Strobl, Mathieu Ouellet
- 
Constructor SummaryConstructorsConstructorDescriptionReactiveGridFsTemplate(DataBufferFactory dataBufferFactory, ReactiveMongoDatabaseFactory dbFactory, MongoConverter converter, String bucket) Creates a newReactiveGridFsTemplateusing the givenDataBufferFactory,ReactiveMongoDatabaseFactoryandMongoConverter.ReactiveGridFsTemplate(ReactiveMongoDatabaseFactory dbFactory, MongoConverter converter) Creates a newReactiveGridFsTemplateusing the givenReactiveMongoDatabaseFactoryandMongoConverter.ReactiveGridFsTemplate(ReactiveMongoDatabaseFactory dbFactory, MongoConverter converter, String bucket) Creates a newReactiveGridFsTemplateusing the givenReactiveMongoDatabaseFactoryandMongoConverter.
- 
Method SummaryModifier and TypeMethodDescriptionprotected com.mongodb.client.gridfs.model.GridFSUploadOptionscomputeUploadOptionsFor(String contentType, org.bson.Document metadata) Compute theGridFSUploadOptionsto be used from the given contentType and metadataDocument.<T> reactor.core.publisher.Flux<T>createFlux(org.springframework.data.mongodb.gridfs.ReactiveGridFsTemplate.ReactiveBucketCallback<T> callback) Create a reusable Flux for aReactiveGridFsTemplate.ReactiveBucketCallback.<T> reactor.core.publisher.Mono<T>createMono(org.springframework.data.mongodb.gridfs.ReactiveGridFsTemplate.ReactiveBucketCallback<T> callback) Create a reusable Mono for aReactiveGridFsTemplate.ReactiveBucketCallback.reactor.core.publisher.Mono<Void>Deletes all files matching the givenQuery.protected reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.gridfs.GridFSBucket>reactor.core.publisher.Flux<com.mongodb.client.gridfs.model.GridFSFile>Returns aFluxemitting all files matching the given query.reactor.core.publisher.Mono<com.mongodb.client.gridfs.model.GridFSFile>Returns aMonoemitting the fristGridFSFilematching the given query orMono.empty()in case no file matches.reactor.core.publisher.Mono<com.mongodb.client.gridfs.model.GridFSFile>Returns aMonoemitting a singleGridFSFilematching the given query orMono.empty()in case no file matches.protected org.bson.DocumentgetMappedQuery(org.bson.Document query) reactor.core.publisher.Mono<ReactiveGridFsResource>getResource(com.mongodb.client.gridfs.model.GridFSFile file) reactor.core.publisher.Mono<ReactiveGridFsResource>getResource(String location) Returns aMonoemitting theReactiveGridFsResourcewith the given file name.reactor.core.publisher.Flux<ReactiveGridFsResource>getResources(String locationPattern) Returns aFluxemitting allReactiveGridFsResources matching the given file name pattern.reactor.core.publisher.Mono<org.bson.types.ObjectId>store(org.reactivestreams.Publisher<DataBuffer> content, String filename, String contentType, Object metadata) Stores the given content into a file with the given name and content type using the given metadata.<T> reactor.core.publisher.Mono<T>store(GridFsObject<T, org.reactivestreams.Publisher<DataBuffer>> upload) protected org.bson.DocumenttoDocument(Object value) Convert a given value into aDocument.
- 
Constructor Details- 
ReactiveGridFsTemplateCreates a newReactiveGridFsTemplateusing the givenReactiveMongoDatabaseFactoryandMongoConverter.- Parameters:
- dbFactory- must not be null.
- converter- must not be null.
 
- 
ReactiveGridFsTemplatepublic ReactiveGridFsTemplate(ReactiveMongoDatabaseFactory dbFactory, MongoConverter converter, @Nullable String bucket) Creates a newReactiveGridFsTemplateusing the givenReactiveMongoDatabaseFactoryandMongoConverter.- Parameters:
- dbFactory- must not be null.
- converter- must not be null.
- bucket-
 
- 
ReactiveGridFsTemplatepublic ReactiveGridFsTemplate(DataBufferFactory dataBufferFactory, ReactiveMongoDatabaseFactory dbFactory, MongoConverter converter, @Nullable String bucket) Creates a newReactiveGridFsTemplateusing the givenDataBufferFactory,ReactiveMongoDatabaseFactoryandMongoConverter.- Parameters:
- dataBufferFactory- must not be null.
- dbFactory- must not be null.
- converter- must not be null.
- bucket-
 
 
- 
- 
Method Details- 
storepublic reactor.core.publisher.Mono<org.bson.types.ObjectId> store(org.reactivestreams.Publisher<DataBuffer> content, @Nullable String filename, @Nullable String contentType, @Nullable Object metadata) Description copied from interface:ReactiveGridFsOperationsStores the given content into a file with the given name and content type using the given metadata. The metadata object will be marshalled before writing.- Specified by:
- storein interface- ReactiveGridFsOperations
- Parameters:
- content- must not be null.
- filename- must not be null or empty.
- contentType- can be null.
- metadata- can be null
- Returns:
- a Monoemitting theObjectIdof theGridFSFilejust created.
 
- 
storepublic <T> reactor.core.publisher.Mono<T> store(GridFsObject<T, org.reactivestreams.Publisher<DataBuffer>> upload) Description copied from interface:ReactiveGridFsOperationsStores the givenGridFsObject, likely aGridFsUpload, into into a file with givenname. If theGridFsObject.getFileId()is set, the file will be stored with that id, otherwise the server auto creates a new id.- Specified by:
- storein interface- ReactiveGridFsOperations
- Type Parameters:
- T- id type of the underlying- GridFSFile
- Parameters:
- upload- the- GridFsObject(most likely a- GridFsUpload) to be stored.
- Returns:
- Monoemitting the id of the stored file which is either an auto created value or- GridFsObject.getFileId().
 
- 
findDescription copied from interface:ReactiveGridFsOperationsReturns aFluxemitting all files matching the given query.
 Note: CurrentlySortcriteria defined at theQuerywill not be regarded as MongoDB does not support ordering for GridFS file access.- Specified by:
- findin interface- ReactiveGridFsOperations
- Parameters:
- query- must not be null.
- Returns:
- Flux.empty()if no mach found.
- See Also:
 
- 
findOneDescription copied from interface:ReactiveGridFsOperationsReturns aMonoemitting a singleGridFSFilematching the given query orMono.empty()in case no file matches.
 NOTE If more than one file matches the given query the resultingMonoemits an error. If you want to obtain the first found file useReactiveGridFsOperations.findFirst(Query).- Specified by:
- findOnein interface- ReactiveGridFsOperations
- Parameters:
- query- must not be null.
- Returns:
- Mono.empty()if not match found.
 
- 
findFirstpublic reactor.core.publisher.Mono<com.mongodb.client.gridfs.model.GridFSFile> findFirst(Query query) Description copied from interface:ReactiveGridFsOperationsReturns aMonoemitting the fristGridFSFilematching the given query orMono.empty()in case no file matches.- Specified by:
- findFirstin interface- ReactiveGridFsOperations
- Parameters:
- query- must not be null.
- Returns:
- Mono.empty()if not match found.
 
- 
deleteDescription copied from interface:ReactiveGridFsOperationsDeletes all files matching the givenQuery.- Specified by:
- deletein interface- ReactiveGridFsOperations
- Parameters:
- query- must not be null.
- Returns:
- a Monosignalling operation completion.
 
- 
getResourceDescription copied from interface:ReactiveGridFsOperationsReturns aMonoemitting theReactiveGridFsResourcewith the given file name.- Specified by:
- getResourcein interface- ReactiveGridFsOperations
- Parameters:
- location- must not be null.
- Returns:
- Mono.empty()if no match found.
 
- 
getResourcepublic reactor.core.publisher.Mono<ReactiveGridFsResource> getResource(com.mongodb.client.gridfs.model.GridFSFile file) Description copied from interface:ReactiveGridFsOperations- Specified by:
- getResourcein interface- ReactiveGridFsOperations
- Parameters:
- file- must not be null.
- Returns:
- Mono.empty()if no match found.
 
- 
getResourcesDescription copied from interface:ReactiveGridFsOperationsReturns aFluxemitting allReactiveGridFsResources matching the given file name pattern.- Specified by:
- getResourcesin interface- ReactiveGridFsOperations
- Parameters:
- locationPattern- must not be null.
- Returns:
- Flux.empty()if no match found.
 
- 
createMonopublic <T> reactor.core.publisher.Mono<T> createMono(org.springframework.data.mongodb.gridfs.ReactiveGridFsTemplate.ReactiveBucketCallback<T> callback) Create a reusable Mono for aReactiveGridFsTemplate.ReactiveBucketCallback. It's up to the developer to choose to obtain a newFluxor to reuse theFlux.- Parameters:
- callback- must not be null
- Returns:
- a Monowrapping theReactiveGridFsTemplate.ReactiveBucketCallback.
 
- 
createFluxpublic <T> reactor.core.publisher.Flux<T> createFlux(org.springframework.data.mongodb.gridfs.ReactiveGridFsTemplate.ReactiveBucketCallback<T> callback) Create a reusable Flux for aReactiveGridFsTemplate.ReactiveBucketCallback. It's up to the developer to choose to obtain a newFluxor to reuse theFlux.- Parameters:
- callback- must not be null
- Returns:
- a Fluxwrapping theReactiveGridFsTemplate.ReactiveBucketCallback.
 
- 
doGetBucketprotected reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.gridfs.GridFSBucket> doGetBucket()
- 
getMappedQueryprotected org.bson.Document getMappedQuery(org.bson.Document query) - Parameters:
- query- pass the given query though a- QueryMapperto apply type conversion.
- Returns:
- never null.
 
- 
computeUploadOptionsForprotected com.mongodb.client.gridfs.model.GridFSUploadOptions computeUploadOptionsFor(@Nullable String contentType, @Nullable org.bson.Document metadata) Compute theGridFSUploadOptionsto be used from the given contentType and metadataDocument.- Parameters:
- contentType- can be null.
- metadata- can be null
- Returns:
- never null.
 
- 
toDocumentConvert a given value into aDocument.- Parameters:
- value- can be null.
- Returns:
- an empty Documentif the source value is null.
 
 
-