Package com.mongodb.client.gridfs
Class GridFSUploadStream
- java.lang.Object
-
- java.io.OutputStream
-
- com.mongodb.client.gridfs.GridFSUploadStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
@NotThreadSafe public abstract class GridFSUploadStream extends java.io.OutputStream
A GridFS OutputStream for uploading data into GridFSProvides the
id
for the file to be uploaded as well as thewrite
methods of aOutputStream
This implementation of a
OutputStream
will not throwIOException
s. However, it will throw aMongoException
if there is an error writing to MongoDB.- Since:
- 3.1
-
-
Constructor Summary
Constructors Constructor Description GridFSUploadStream()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract void
abort()
Aborts the upload and deletes any data.abstract void
close()
void
flush()
abstract ObjectId
getFileId()
Deprecated.usegetObjectId()
instead.abstract BsonValue
getId()
Gets theBsonValue
for the file to be uploadedabstract ObjectId
getObjectId()
Gets theObjectId
for the file to be uploaded or throws an error if an alternative BsonType has been used for the id.abstract void
write(byte[] b)
abstract void
write(byte[] b, int off, int len)
abstract void
write(int b)
-
-
-
Method Detail
-
getFileId
@Deprecated public abstract ObjectId getFileId()
Deprecated.usegetObjectId()
instead.Gets theObjectId
for the file to be uploaded Throws aMongoGridFSException
if the file id is not an ObjectId.- Returns:
- the ObjectId for the file to be uploaded
-
getObjectId
public abstract ObjectId getObjectId()
Gets theObjectId
for 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
-
getId
public abstract BsonValue getId()
Gets theBsonValue
for the file to be uploaded- Returns:
- the BsonValue for the file to be uploaded
-
abort
public abstract void abort()
Aborts the upload and deletes any data.
-
write
public abstract void write(int b)
- Specified by:
write
in classjava.io.OutputStream
-
write
public abstract void write(byte[] b)
- Overrides:
write
in classjava.io.OutputStream
-
write
public abstract void write(byte[] b, int off, int len)
- Overrides:
write
in classjava.io.OutputStream
-
flush
public void flush()
- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.OutputStream
-
close
public abstract void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
-
-