File tree Expand file tree Collapse file tree 1 file changed +2
-0
lines changed
source/includes/fundamentals/code-snippets Expand file tree Collapse file tree 1 file changed +2
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ private static void uploadFromOutputStream(GridFSBucket gridFSBucket) throws Exc
70
70
71
71
try (GridFSUploadStream uploadStream = gridFSBucket .openUploadStream ("myProject.zip" , options )) {
72
72
uploadStream .write (data );
73
+ uploadStream .flush ();
73
74
System .out .println ("The file id of the uploaded file is: " + uploadStream .getObjectId ().toHexString ());
74
75
} catch (Exception e ) {
75
76
System .err .println ("The file upload failed: " + e );
@@ -109,6 +110,7 @@ private static void downloadToOutputStream(GridFSBucket gridFSBucket) throws Exc
109
110
110
111
try (FileOutputStream streamToDownloadTo = new FileOutputStream ("/tmp/myProject.zip" )) {
111
112
gridFSBucket .downloadToStream ("myProject.zip" , streamToDownloadTo , downloadOptions );
113
+ streamToDownloadTo .flush ();
112
114
}
113
115
// end downloadToStream
114
116
}
You can’t perform that action at this time.
0 commit comments