Skip to content

Commit e18f506

Browse files
nhhmp911de
authored andcommitted
DATAMONGO-2021 - Use getObjectId() instead of getFilename() for opening the GridFS download stream.
Using the file name leads to duplicate resource streams as file names are not unique therefore we're using the file's ObjectId to lookup the file content. Original pull request: spring-projects#581.
1 parent 46ed58b commit e18f506

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/gridfs/GridFsTemplate.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public GridFsResource getResource(GridFSFile file) {
240240

241241
Assert.notNull(file, "GridFSFile must not be null!");
242242

243-
return new GridFsResource(file, getGridFs().openDownloadStream(file.getFilename()));
243+
return new GridFsResource(file, getGridFs().openDownloadStream(file.getObjectId()));
244244
}
245245

246246
/*

0 commit comments

Comments
 (0)