@@ -232,7 +232,7 @@ public void remove( DBObject query ){
232
232
* @return
233
233
*/
234
234
public GridFSInputFile createFile ( byte [] data ){
235
- return createFile ( new ByteArrayInputStream ( data ) );
235
+ return createFile ( new ByteArrayInputStream ( data ), true );
236
236
}
237
237
238
238
@@ -245,7 +245,7 @@ public GridFSInputFile createFile( byte[] data ){
245
245
*/
246
246
public GridFSInputFile createFile ( File f )
247
247
throws IOException {
248
- return createFile ( new FileInputStream ( f ) , f .getName () );
248
+ return createFile ( new FileInputStream ( f ) , f .getName (), true );
249
249
}
250
250
251
251
/**
@@ -258,6 +258,18 @@ public GridFSInputFile createFile( InputStream in ){
258
258
return createFile ( in , null );
259
259
}
260
260
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
+
261
273
/**
262
274
* creates a file entry.
263
275
* After calling this method, you have to call save() on the GridFSInputFile file
@@ -269,6 +281,19 @@ public GridFSInputFile createFile( InputStream in , String filename ){
269
281
return new GridFSInputFile ( this , in , filename );
270
282
}
271
283
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
+
272
297
/**
273
298
* @see {@link GridFS#createFile()} on how to use this method
274
299
* @param filename the file name as stored in the db
0 commit comments