Package com.mongodb.client.gridfs
Class GridFSUploadStream
- java.lang.Object
- 
- java.io.OutputStream
- 
- com.mongodb.client.gridfs.GridFSUploadStream
 
 
- 
- All Implemented Interfaces:
- Closeable,- Flushable,- AutoCloseable
 
 @NotThreadSafe public abstract class GridFSUploadStream extends OutputStream A GridFS OutputStream for uploading data into GridFSProvides the idfor the file to be uploaded as well as thewritemethods of aOutputStreamThis implementation of a OutputStreamwill not throwIOExceptions. However, it will throw aMongoExceptionif there is an error writing to MongoDB.- Since:
- 3.1
 
- 
- 
Constructor SummaryConstructors Constructor Description GridFSUploadStream()
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract voidabort()Aborts the upload and deletes any data.abstract voidclose()voidflush()abstract ObjectIdgetFileId()Deprecated.usegetObjectId()instead.abstract BsonValuegetId()Gets theBsonValuefor the file to be uploadedabstract ObjectIdgetObjectId()Gets theObjectIdfor the file to be uploaded or throws an error if an alternative BsonType has been used for the id.abstract voidwrite(byte[] b)abstract voidwrite(byte[] b, int off, int len)abstract voidwrite(int b)- 
Methods inherited from class java.io.OutputStreamnullOutputStream
 
- 
 
- 
- 
- 
Method Detail- 
getFileId@Deprecated public abstract ObjectId getFileId() Deprecated.usegetObjectId()instead.Gets theObjectIdfor the file to be uploaded Throws aMongoGridFSExceptionif the file id is not an ObjectId.- Returns:
- the ObjectId for the file to be uploaded
 
 - 
getObjectIdpublic abstract ObjectId getObjectId() Gets theObjectIdfor the file to be uploaded or throws an error if an alternative BsonType has been used for the id. Throws a MongoGridFSException if the file id is not an ObjectId.- Returns:
- the ObjectId for the file to be uploaded
 
 - 
getIdpublic abstract BsonValue getId() Gets theBsonValuefor the file to be uploaded- Returns:
- the BsonValue for the file to be uploaded
 
 - 
abortpublic abstract void abort() Aborts the upload and deletes any data.
 - 
writepublic abstract void write(int b) - Specified by:
- writein class- OutputStream
 
 - 
writepublic abstract void write(byte[] b) - Overrides:
- writein class- OutputStream
 
 - 
writepublic abstract void write(byte[] b, int off, int len)- Overrides:
- writein class- OutputStream
 
 - 
flushpublic void flush() - Specified by:
- flushin interface- Flushable
- Overrides:
- flushin class- OutputStream
 
 - 
closepublic abstract void close() - Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Overrides:
- closein class- OutputStream
 
 
- 
 
-