@@ -232,7 +232,7 @@ public void remove( DBObject query ){
232232 * @return
233233 */
234234 public GridFSInputFile createFile ( byte [] data ){
235- return createFile ( new ByteArrayInputStream ( data ) );
235+ return createFile ( new ByteArrayInputStream ( data ), true );
236236 }
237237
238238
@@ -245,7 +245,7 @@ public GridFSInputFile createFile( byte[] data ){
245245 */
246246 public GridFSInputFile createFile ( File f )
247247 throws IOException {
248- return createFile ( new FileInputStream ( f ) , f .getName () );
248+ return createFile ( new FileInputStream ( f ) , f .getName (), true );
249249 }
250250
251251 /**
@@ -258,6 +258,18 @@ public GridFSInputFile createFile( InputStream in ){
258258 return createFile ( in , null );
259259 }
260260
261+ /**
262+ * creates a file entry.
263+ * after calling this method, you have to call save() on the GridFSInputFile file
264+ * @param in an inputstream containing the file's data
265+ * @param closeStreamOnPersist indicate the passed in input stream should be closed
266+ * once the data chunk persisted
267+ * @return
268+ */
269+ public GridFSInputFile createFile ( InputStream in , boolean closeStreamOnPersist ){
270+ return createFile ( in , null , closeStreamOnPersist );
271+ }
272+
261273 /**
262274 * creates a file entry.
263275 * After calling this method, you have to call save() on the GridFSInputFile file
@@ -269,6 +281,19 @@ public GridFSInputFile createFile( InputStream in , String filename ){
269281 return new GridFSInputFile ( this , in , filename );
270282 }
271283
284+ /**
285+ * creates a file entry.
286+ * After calling this method, you have to call save() on the GridFSInputFile file
287+ * @param in an inputstream containing the file's data
288+ * @param filename the file name as stored in the db
289+ * @param closeStreamOnPersist indicate the passed in input stream should be closed
290+ * once the data chunk persisted
291+ * @return
292+ */
293+ public GridFSInputFile createFile ( InputStream in , String filename , boolean closeStreamOnPersist ){
294+ return new GridFSInputFile ( this , in , filename , closeStreamOnPersist );
295+ }
296+
272297 /**
273298 * @see {@link GridFS#createFile()} on how to use this method
274299 * @param filename the file name as stored in the db
0 commit comments