Skip to content

Commit b057374

Browse files
added flush() method call (#141)
1 parent 6226f3e commit b057374

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

source/includes/fundamentals/code-snippets/GridFSOperations.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ private static void uploadFromOutputStream(GridFSBucket gridFSBucket) throws Exc
7070

7171
try (GridFSUploadStream uploadStream = gridFSBucket.openUploadStream("myProject.zip", options)) {
7272
uploadStream.write(data);
73+
uploadStream.flush();
7374
System.out.println("The file id of the uploaded file is: " + uploadStream.getObjectId().toHexString());
7475
} catch (Exception e) {
7576
System.err.println("The file upload failed: " + e);
@@ -109,6 +110,7 @@ private static void downloadToOutputStream(GridFSBucket gridFSBucket) throws Exc
109110

110111
try (FileOutputStream streamToDownloadTo = new FileOutputStream("/tmp/myProject.zip")) {
111112
gridFSBucket.downloadToStream("myProject.zip", streamToDownloadTo, downloadOptions);
113+
streamToDownloadTo.flush();
112114
}
113115
// end downloadToStream
114116
}

0 commit comments

Comments
 (0)