List of usage examples for org.springframework.data.mongodb.gridfs GridFsResource GridFsResource
public GridFsResource(GridFSFile file)
From source file:org.swarmcom.jsynapse.dao.ContentRepositoryImpl.java
@Override public ContentResource download(String mediaId) { GridFSDBFile file = gridFsTemplate.findOne(Query.query(Criteria.where("_id").is(mediaId))); if (null == file) { return null; }/* w w w.j a v a2s . c om*/ GridFsResource gridFsResource = new GridFsResource(file); return new ContentResource(gridFsResource.getContentType(), file.getLength(), gridFsResource); }
From source file:com.sangupta.dryrun.mongo.DryRunGridFSTemplate.java
@Override public GridFsResource getResource(String fileName) { DryRunGridFSDBFile file = this.files.get(fileName); if (file == null) { return null; }//from ww w . ja v a 2s . c o m return new GridFsResource(file); }
From source file:com.sangupta.dryrun.mongo.DryRunGridFSTemplate.java
@Override public GridFsResource[] getResources(String filenamePattern) { if (AssertUtils.isEmpty(filenamePattern)) { return new GridFsResource[0]; }//from w w w .java 2 s . c om DryRunAntPath path = new DryRunAntPath(filenamePattern); if (path.isPattern()) { Query query = Query.query(Criteria.where("filename").regex(path.toRegex())); List<GridFSDBFile> files = this.findObjects(query.getQueryObject(), -1); List<GridFsResource> resources = new ArrayList<GridFsResource>(files.size()); for (GridFSDBFile file : files) { resources.add(new GridFsResource(file)); } return resources.toArray(new GridFsResource[resources.size()]); } return new GridFsResource[] { getResource(filenamePattern) }; }