File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/gridfs Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 51
51
* @author Martin Baumgartner
52
52
* @author Christoph Strobl
53
53
* @author Mark Paluch
54
+ * @author Niklas Helge Hanft
54
55
*/
55
56
public class GridFsTemplate implements GridFsOperations , ResourcePatternResolver {
56
57
@@ -228,7 +229,7 @@ public ClassLoader getClassLoader() {
228
229
public GridFsResource getResource (String location ) {
229
230
230
231
GridFSFile file = findOne (query (whereFilename ().is (location )));
231
- return file != null ? new GridFsResource (file , getGridFs ().openDownloadStream (location )) : null ;
232
+ return file != null ? new GridFsResource (file , getGridFs ().openDownloadStream (file . getObjectId () )) : null ;
232
233
}
233
234
234
235
/*
@@ -246,13 +247,13 @@ public GridFsResource[] getResources(String locationPattern) {
246
247
if (path .isPattern ()) {
247
248
248
249
GridFSFindIterable files = find (query (whereFilename ().regex (path .toRegex ())));
249
- List <GridFsResource > resources = new ArrayList <GridFsResource >();
250
+ List <GridFsResource > resources = new ArrayList <>();
250
251
251
252
for (GridFSFile file : files ) {
252
- resources .add (new GridFsResource (file , getGridFs ().openDownloadStream (file .getFilename ())));
253
+ resources .add (new GridFsResource (file , getGridFs ().openDownloadStream (file .getObjectId ())));
253
254
}
254
255
255
- return resources .toArray (new GridFsResource [resources . size () ]);
256
+ return resources .toArray (new GridFsResource [0 ]);
256
257
}
257
258
258
259
return new GridFsResource [] { getResource (locationPattern ) };
You can’t perform that action at this time.
0 commit comments