List of usage examples for org.springframework.data.mongodb.gridfs GridFsResource getFilename
@Override public String getFilename() throws IllegalStateException
From source file:piecework.util.ContentUtility.java
public static ContentResource toContent(GridFsResource resource) throws IOException { String resourceId = resource.getId().toString(); return new BasicContentResource.Builder().contentId(resourceId).contentType(resource.getContentType()) .filename(resource.getFilename()).location(resource.getFilename()) .inputStream(resource.getInputStream()).lastModified(resource.lastModified()) .length(Long.valueOf(resource.contentLength())).build(); }
From source file:com.greglturnquist.springagram.fileservice.mongodb.FileService.java
public void deleteAll() { for (GridFsResource resource : this.gridFsTemplate.getResources("*")) { this.deleteOne(resource.getFilename()); }//from w w w .java 2 s . co m }
From source file:com.greglturnquist.springagram.fileservice.mongodb.ApplicationController.java
@RequestMapping(method = RequestMethod.GET, value = "/files") public ResponseEntity<ResourceSupport> listAllFiles() { ResourceSupport files = new ResourceSupport(); for (GridFsResource resource : this.fileService.findAll()) { files.add(linkTo(methodOn(ApplicationController.class).getFile(resource.getFilename())) .withRel(resource.getFilename())); }//from w ww . j a va 2 s . com return ResponseEntity.ok(files); }