com.mongodb.MongoGridFSException Java Examples
The following examples show how to use
com.mongodb.MongoGridFSException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MongodbGridfsResource.java From camel-quarkus with Apache License 2.0 | 6 votes |
@Path("/get/{fileName}") @GET @Produces(MediaType.TEXT_PLAIN) public Response retrieveFile(@PathParam("fileName") String fileName) { String result = null; try { result = producerTemplate.requestBodyAndHeader("mongodb-gridfs:camelMongoClient?database=test&operation=findOne", null, Exchange.FILE_NAME, fileName, String.class); } catch (Exception e) { if (e.getCause() instanceof MongoGridFSException) { return Response.status(404).build(); } } return Response.ok().entity(result).build(); }
Example #2
Source File: MongoDBArtifactStore.java From hawkbit-extensions with Eclipse Public License 1.0 | 6 votes |
@SuppressWarnings("squid:S2589") // False positive: file.getMetadata() can return null private static final String getContentType(final GridFSFile file) { final Document metadata = file.getMetadata(); String contentType = null; if (metadata != null) { contentType = metadata.getString(CONTENT_TYPE); } if (contentType == null) { try { contentType = file.getContentType(); } catch (final MongoGridFSException e) { throw new ArtifactStoreException("Could not determine content type for file " + file.getId(), e); } } return contentType; }