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 . |
reactor.core.publisher.Mono<Void> |
delete(Query query)
Deletes all files matching the given
Query . |
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 com.mongodb.reactivestreams.client.gridfs.GridFSBucket |
getGridFs() |
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 ReactiveGridFsResource s matching the given file name pattern. |
protected com.mongodb.reactivestreams.client.gridfs.GridFSFindPublisher |
prepareQuery(Query query) |
reactor.core.publisher.Mono<org.bson.types.ObjectId> |
store(com.mongodb.reactivestreams.client.gridfs.AsyncInputStream content,
String filename,
String contentType,
org.bson.Document metadata)
Stores the given content into a file with the given name and content type using the given metadata.
|
reactor.core.publisher.Mono<org.bson.types.ObjectId> |
store(com.mongodb.reactivestreams.client.gridfs.AsyncInputStream 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.
|
reactor.core.publisher.Mono<org.bson.types.ObjectId> |
store(org.reactivestreams.Publisher<DataBuffer> content,
String filename,
String contentType,
org.bson.Document metadata)
Stores the given content into a file with the given name and content type using the given metadata.
|
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(com.mongodb.reactivestreams.client.gridfs.AsyncInputStream content, @Nullable String filename, @Nullable String contentType, @Nullable Object metadata)
ReactiveGridFsOperations
store
in interface ReactiveGridFsOperations
content
- 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 reactor.core.publisher.Mono<org.bson.types.ObjectId> store(org.reactivestreams.Publisher<DataBuffer> content, @Nullable String filename, @Nullable String contentType, @Nullable Object metadata)
ReactiveGridFsOperations
store
in interface ReactiveGridFsOperations
content
- 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 reactor.core.publisher.Mono<org.bson.types.ObjectId> store(com.mongodb.reactivestreams.client.gridfs.AsyncInputStream content, @Nullable String filename, @Nullable String contentType, @Nullable org.bson.Document metadata)
ReactiveGridFsOperations
store
in interface ReactiveGridFsOperations
content
- must not be null.filename
- must not be null or empty.contentType
- can be null.metadata
- can be null.Mono
emitting the ObjectId
of the GridFSFile
just
created.public reactor.core.publisher.Mono<org.bson.types.ObjectId> store(org.reactivestreams.Publisher<DataBuffer> content, @Nullable String filename, @Nullable String contentType, @Nullable org.bson.Document metadata)
ReactiveGridFsOperations
store
in interface ReactiveGridFsOperations
content
- must not be null.filename
- must not be null or empty.contentType
- can be null.metadata
- can be null.Mono
emitting the ObjectId
of the GridFSFile
just
created.public reactor.core.publisher.Flux<com.mongodb.client.gridfs.model.GridFSFile> find(Query query)
ReactiveGridFsOperations
Flux
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 ReactiveGridFsOperations
query
- must not be null.Flux.empty()
if no mach found.public reactor.core.publisher.Mono<com.mongodb.client.gridfs.model.GridFSFile> findOne(Query query)
ReactiveGridFsOperations
Mono
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 ReactiveGridFsOperations
query
- must not be null.Mono.empty()
if not match found.public reactor.core.publisher.Mono<com.mongodb.client.gridfs.model.GridFSFile> findFirst(Query query)
ReactiveGridFsOperations
Mono
emitting the frist GridFSFile
matching the given
query or Mono.empty()
in case no file matches.findFirst
in interface ReactiveGridFsOperations
query
- must not be null.Mono.empty()
if not match found.public reactor.core.publisher.Mono<Void> delete(Query query)
ReactiveGridFsOperations
Query
.delete
in interface ReactiveGridFsOperations
query
- must not be null.Mono
signalling operation completion.public reactor.core.publisher.Mono<ReactiveGridFsResource> getResource(String location)
ReactiveGridFsOperations
Mono
emitting the ReactiveGridFsResource
with the given file name.getResource
in interface ReactiveGridFsOperations
location
- must not be null.Mono.empty()
if no match found.public reactor.core.publisher.Mono<ReactiveGridFsResource> getResource(com.mongodb.client.gridfs.model.GridFSFile file)
ReactiveGridFsOperations
getResource
in interface ReactiveGridFsOperations
file
- must not be null.Mono.empty()
if no match found.public reactor.core.publisher.Flux<ReactiveGridFsResource> getResources(String locationPattern)
ReactiveGridFsOperations
Flux
emitting all ReactiveGridFsResource
s matching the given file name pattern.getResources
in interface ReactiveGridFsOperations
locationPattern
- must not be null.Flux.empty()
if no match found.protected com.mongodb.reactivestreams.client.gridfs.GridFSFindPublisher prepareQuery(Query query)
protected com.mongodb.reactivestreams.client.gridfs.GridFSBucket getGridFs()
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–2021 Pivotal Software, Inc.. All rights reserved.