// Optional bucket, default is "fs"
String bucket = jsonObject.getString("bucket", GridFS.DEFAULT_BUCKET);
GridFS files = new GridFS(db, bucket);
GridFSDBFile file = files.findOne(objectId);
if (file == null) {
sendError(message, "File does not exist: " + objectId.toString());
return;
}
JsonObject fileInfo = new JsonObject()
.putString("filename", file.getFilename())
.putString("contentType", file.getContentType())
.putNumber("length", file.getLength())
.putNumber("chunkSize", file.getChunkSize())
.putNumber("uploadDate", file.getUploadDate().getTime());
DBObject metadata = file.getMetaData();
if (metadata != null) {
fileInfo.putObject("metadata", new JsonObject(JSON.serialize(metadata)));
}
// Send file info