Class GridFSUploadStream

  • All Implemented Interfaces:
    , ,

    @NotThreadSafe
    public abstract class GridFSUploadStream
    extends 
    A GridFS OutputStream for uploading data into GridFS

    Provides the id for the file to be uploaded as well as the write methods of a

    This implementation of a OutputStream will not throw s. However, it will throw a MongoException if there is an error writing to MongoDB.

    Since:
    3.1
    • Constructor Detail

      • GridFSUploadStream

        public GridFSUploadStream()
    • Method Detail

      • getFileId

        public abstract ObjectId getFileId()
        Deprecated.
        use getObjectId() instead.
        Gets the ObjectId for the file to be uploaded Throws a MongoGridFSException if the file id is not an ObjectId.
        Returns:
        the ObjectId for the file to be uploaded
      • getObjectId

        public abstract ObjectId getObjectId()
        Gets the ObjectId 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 the BsonValue 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:
         in class 
      • write

        public abstract void write​(byte[] b)
        Overrides:
         in class 
      • write

        public abstract void write​(byte[] b,
                                   int off,
                                   int len)
        Overrides:
         in class 
      • flush

        public void flush()
        Specified by:
         in interface 
        Overrides:
         in class 
      • close

        public abstract void close()
        Specified by:
         in interface 
        Specified by:
         in interface 
        Overrides:
         in class