public class ReactiveGridFsTemplate extends Object implements ReactiveGridFsOperations
ReactiveGridFsOperations implementation to store content into MongoDB GridFS. Uses by default
DefaultDataBufferFactory to create buffers.| Constructor and Description |
|---|
ReactiveGridFsTemplate(DataBufferFactory dataBufferFactory,
ReactiveMongoDatabaseFactory dbFactory,
MongoConverter converter,
String bucket)
Creates a new
ReactiveGridFsTemplate using the given DataBufferFactory,
ReactiveMongoDatabaseFactory and MongoConverter. |
ReactiveGridFsTemplate(ReactiveMongoDatabaseFactory dbFactory,
MongoConverter converter)
Creates a new
ReactiveGridFsTemplate using the given ReactiveMongoDatabaseFactory and
MongoConverter. |
ReactiveGridFsTemplate(ReactiveMongoDatabaseFactory dbFactory,
MongoConverter converter,
String bucket)
Creates a new
ReactiveGridFsTemplate using the given ReactiveMongoDatabaseFactory and
MongoConverter. |
| Modifier and Type | Method and Description |
|---|---|
protected com.mongodb.client.gridfs.model.GridFSUploadOptions |
computeUploadOptionsFor(String contentType,
org.bson.Document metadata)
Compute the
GridFSUploadOptions to be used from the given contentType and metadata
Document. |
<T> reactor.core.publisher.Flux<T> |
createFlux(org.springframework.data.mongodb.gridfs.ReactiveGridFsTemplate.ReactiveBucketCallback<T> callback)
Create a reusable Flux for a
ReactiveBucketCallback. |
<T> reactor.core.publisher.Mono<T> |
createMono(org.springframework.data.mongodb.gridfs.ReactiveGridFsTemplate.ReactiveBucketCallback<T> callback)
Create a reusable Mono for a
ReactiveBucketCallback. |
reactor.core.publisher.Mono<Void> |
delete(Query query)
Deletes all files matching the given
Query. |
protected reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.gridfs.GridFSBucket> |
doGetBucket() |
reactor.core.publisher.Flux<com.mongodb.client.gridfs.model.GridFSFile> |
find(Query query)
Returns a
Flux emitting all files matching the given query. |
reactor.core.publisher.Mono<com.mongodb.client.gridfs.model.GridFSFile> |
findFirst(Query query)
Returns a
Mono emitting the frist GridFSFile matching the given
query or Mono.empty() in case no file matches. |
reactor.core.publisher.Mono<com.mongodb.client.gridfs.model.GridFSFile> |
findOne(Query query)
Returns a
Mono emitting a single GridFSFile matching the given
query or Mono.empty() in case no file matches. |
protected org.bson.Document |
getMappedQuery(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 a
Mono emitting the ReactiveGridFsResource with the given file name. |
reactor.core.publisher.Flux<ReactiveGridFsResource> |
getResources(String locationPattern)
Returns a
Flux emitting all ReactiveGridFsResources matching the given file name pattern. |
<T> reactor.core.publisher.Mono<T> |
store(GridFsObject<T,org.reactivestreams.Publisher<DataBuffer>> upload)
|
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.
|
protected org.bson.Document |
toDocument(Object value)
Convert a given value into a
Document. |
public ReactiveGridFsTemplate(ReactiveMongoDatabaseFactory dbFactory, MongoConverter converter)
ReactiveGridFsTemplate using the given ReactiveMongoDatabaseFactory and
MongoConverter.dbFactory - must not be null.converter - must not be null.public ReactiveGridFsTemplate(ReactiveMongoDatabaseFactory dbFactory, MongoConverter converter, @Nullable String bucket)
ReactiveGridFsTemplate using the given ReactiveMongoDatabaseFactory and
MongoConverter.dbFactory - must not be null.converter - must not be null.bucket - public ReactiveGridFsTemplate(DataBufferFactory dataBufferFactory, ReactiveMongoDatabaseFactory dbFactory, MongoConverter converter, @Nullable String bucket)
ReactiveGridFsTemplate using the given DataBufferFactory,
ReactiveMongoDatabaseFactory and MongoConverter.dataBufferFactory - must not be null.dbFactory - must not be null.converter - must not be null.bucket - public reactor.core.publisher.Mono<org.bson.types.ObjectId> store(org.reactivestreams.Publisher<DataBuffer> content, @Nullable String filename, @Nullable String contentType, @Nullable Object metadata)
ReactiveGridFsOperationsstore in interface ReactiveGridFsOperationscontent - must not be null.filename - must not be null or empty.contentType - can be null.metadata - can be nullMono emitting the ObjectId of the GridFSFile just
created.public <T> reactor.core.publisher.Mono<T> store(GridFsObject<T,org.reactivestreams.Publisher<DataBuffer>> upload)
ReactiveGridFsOperationsGridFsObject, likely a GridFsUpload, into into a file with given
name. If the GridFsObject.getFileId() is set, the file will be stored
with that id, otherwise the server auto creates a new id. store in interface ReactiveGridFsOperationsT - id type of the underlying GridFSFileupload - the GridFsObject (most likely a GridFsUpload) to be stored.Mono emitting the id of the stored file which is either an auto created value or
GridFsObject.getFileId().public reactor.core.publisher.Flux<com.mongodb.client.gridfs.model.GridFSFile> find(Query query)
ReactiveGridFsOperationsFlux emitting all files matching the given query. Sort criteria defined at the Query will not be regarded as MongoDB
does not support ordering for GridFS file access.find in interface ReactiveGridFsOperationsquery - must not be null.Flux.empty() if no mach found.public reactor.core.publisher.Mono<com.mongodb.client.gridfs.model.GridFSFile> findOne(Query query)
ReactiveGridFsOperationsMono emitting a single GridFSFile matching the given
query or Mono.empty() in case no file matches. Mono emits an error. If
you want to obtain the first found file use ReactiveGridFsOperations.findFirst(Query).findOne in interface ReactiveGridFsOperationsquery - must not be null.Mono.empty() if not match found.public reactor.core.publisher.Mono<com.mongodb.client.gridfs.model.GridFSFile> findFirst(Query query)
ReactiveGridFsOperationsMono emitting the frist GridFSFile matching the given
query or Mono.empty() in case no file matches.findFirst in interface ReactiveGridFsOperationsquery - must not be null.Mono.empty() if not match found.public reactor.core.publisher.Mono<Void> delete(Query query)
ReactiveGridFsOperationsQuery.delete in interface ReactiveGridFsOperationsquery - must not be null.Mono signalling operation completion.public reactor.core.publisher.Mono<ReactiveGridFsResource> getResource(String location)
ReactiveGridFsOperationsMono emitting the ReactiveGridFsResource with the given file name.getResource in interface ReactiveGridFsOperationslocation - must not be null.Mono.empty() if no match found.public reactor.core.publisher.Mono<ReactiveGridFsResource> getResource(com.mongodb.client.gridfs.model.GridFSFile file)
ReactiveGridFsOperationsgetResource in interface ReactiveGridFsOperationsfile - must not be null.Mono.empty() if no match found.public reactor.core.publisher.Flux<ReactiveGridFsResource> getResources(String locationPattern)
ReactiveGridFsOperationsFlux emitting all ReactiveGridFsResources matching the given file name pattern.getResources in interface ReactiveGridFsOperationslocationPattern - must not be null.Flux.empty() if no match found.public <T> reactor.core.publisher.Mono<T> createMono(org.springframework.data.mongodb.gridfs.ReactiveGridFsTemplate.ReactiveBucketCallback<T> callback)
ReactiveBucketCallback. It's up to the developer to choose to obtain a new
Flux or to reuse the Flux.callback - must not be nullMono wrapping the ReactiveBucketCallback.public <T> reactor.core.publisher.Flux<T> createFlux(org.springframework.data.mongodb.gridfs.ReactiveGridFsTemplate.ReactiveBucketCallback<T> callback)
ReactiveBucketCallback. It's up to the developer to choose to obtain a new
Flux or to reuse the Flux.callback - must not be nullFlux wrapping the ReactiveBucketCallback.protected reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.gridfs.GridFSBucket> doGetBucket()
protected org.bson.Document getMappedQuery(org.bson.Document query)
query - pass the given query though a QueryMapper to apply type conversion.protected com.mongodb.client.gridfs.model.GridFSUploadOptions computeUploadOptionsFor(@Nullable String contentType, @Nullable org.bson.Document metadata)
GridFSUploadOptions to be used from the given contentType and metadata
Document.contentType - can be null.metadata - can be nullCopyright © 2011–2023 Pivotal Software, Inc.. All rights reserved.