public class

GridFSInputFile

extends GridFSFile
java.lang.Object
   ↳ com.mongodb.gridfs.GridFSFile
     ↳ com.mongodb.gridfs.GridFSInputFile

Class Overview

This class represents a GridFS file to be written to the database Operations include: - writing data obtained from an InputStream - getting an OutputStream to stream the data out

Summary

[Expand]
Inherited Fields
From class com.mongodb.gridfs.GridFSFile
Public Methods
OutputStream getOutputStream()
After retrieving this OutputStream, this object will be capable of accepting successively written data to the output stream.
void save()
calls save(long) with the existing chunk size
void save(long chunkSize)
This method first calls saveChunks(long) if the file data has not been saved yet.
int saveChunks(long chunkSize)
Saves all data into chunks from configured InputStream input stream to GridFS.
int saveChunks()
void setChunkSize(long _chunkSize)
Set the chunk size.
void setContentType(String ct)
Sets the content type (MIME type) on the GridFS entry.
void setFilename(String fn)
Sets the file name on the GridFS entry.
void setId(Object id)
[Expand]
Inherited Methods
From class com.mongodb.gridfs.GridFSFile
From class java.lang.Object
From interface com.mongodb.DBObject
From interface org.bson.BSONObject

Public Methods

public OutputStream getOutputStream ()

After retrieving this OutputStream, this object will be capable of accepting successively written data to the output stream. To completely persist this GridFS object, you must finally call the close() method on the output stream. Note that calling the save() and saveChunks() methods will throw Exceptions once you obtained the OutputStream.

Returns
  • Writable stream object.

public void save ()

calls save(long) with the existing chunk size

public void save (long chunkSize)

This method first calls saveChunks(long) if the file data has not been saved yet. Then it persists the file entry to GridFS.

Parameters
chunkSize Size of chunks for file in bytes.

public int saveChunks (long chunkSize)

Saves all data into chunks from configured InputStream input stream to GridFS. A non-default chunk size can be specified. This method does NOT save the file object itself, one must call save() to do so.

Parameters
chunkSize Size of chunks for file in bytes.
Returns
  • Number of the next chunk.
Throws
IOException on problems reading the new entry's InputStream.

public int saveChunks ()

Returns
  • Number of the next chunk.
Throws
IOException on problems reading the new entry's InputStream.
See Also

public void setChunkSize (long _chunkSize)

Set the chunk size. This must be called before saving any data.

public void setContentType (String ct)

Sets the content type (MIME type) on the GridFS entry.

Parameters
ct Content type.

public void setFilename (String fn)

Sets the file name on the GridFS entry.

Parameters
fn File name.

public void setId (Object id)