I am beginning a new project with Quarkus and want to use MongoDB as our datastore.
We want to upload/dowload large files (> 100MB) via REST (multipart-form) and archive them in a MongoDB along with some metadata for later retrieval.
I read that GridFS is perfect for this and was wondering if Quarkus supports it out of the box?
All I can find is the Quarkus MongoDB Client documentation and MongoDB Panache documentation. But nothing specially saying GridFS support for large files.
https://quarkus.io/guides/mongodb-panache https://quarkus.io/guides/mongodb
I do see however links for 'Apache Camel Quarkus' that DOES has gridFS support. And apparently it uses the Quarkus MongoDB
client underneath.
https://camel.apache.org/camel-quarkus/2.15.x/reference/extensions/mongodb-gridfs.html
I suppose I could use Quarkus-Camel and just call the component to do the work, but before I went that route I wanted to know if there was a pure Quarkus way.
Any examples would be appreciated of either pure Quarkus/Panache or Apache Camel Quarkus integration.
I want to go MongoDB route rather than storing on FileSystem/Database records because I don't want to worry about transactional issues and rollbacks if I can't write a file to the FS or write the meta to the DB. I want to just store everything in one location using the large file support of Mongo.
Thanks!
CodePudding user response:
Right now, there is no panache-repository support for gridFS. But you can access the underlying gridFS pretty straight forward:
@Inject
public GridFSRepository(
@ConfigProperty(name = "quarkus.mongodb.database") String databaseName,
@ConfigProperty(name = "gridfs.bucket") String bucketName,
MongoClient mongoClient) {
MongoDatabase database = mongoClient.getDatabase(databaseName);
gridFSBucket = GridFSBuckets.create(database, bucketName);
}