/** * Saves all data into chunks from configured {@link java.io.InputStream} input stream to GridFS. * * @return Number of the next chunk. * @throws IOException on problems reading the new entry's {@link java.io.InputStream}. * @throws MongoException if there's a failure * @see com.mongodb.gridfs.GridFSInputFile#saveChunks(long) */ public int saveChunks() throws IOException { return saveChunks(chunkSize); }
/** * This method first calls saveChunks(long) if the file data has not been saved yet. Then it persists the file entry to GridFS. * * @param chunkSize Size of chunks for file in bytes. * @throws MongoException if there's a problem saving the file. */ public void save(final long chunkSize) { if (outputStream != null) { throw new MongoException("cannot mix OutputStream and regular save()"); } // note that chunkSize only changes chunkSize in case we actually save chunks // otherwise there is a risk file and chunks are not compatible if (!savedChunks) { try { saveChunks(chunkSize); } catch (IOException ioe) { throw new MongoException("couldn't save chunks", ioe); } } super.save(); }
/** * Saves all data into chunks from configured {@link java.io.InputStream} input stream to GridFS. * * @return Number of the next chunk. * @throws IOException on problems reading the new entry's {@link java.io.InputStream}. * @throws MongoException if there's a failure * @see com.mongodb.gridfs.GridFSInputFile#saveChunks(long) */ public int saveChunks() throws IOException { return saveChunks(chunkSize); }
/** * This method first calls saveChunks(long) if the file data has not been saved yet. Then it persists the file entry to GridFS. * * @param chunkSize Size of chunks for file in bytes. * @throws MongoException if there's a problem saving the file. */ public void save(final long chunkSize) { if (outputStream != null) { throw new MongoException("cannot mix OutputStream and regular save()"); } // note that chunkSize only changes chunkSize in case we actually save chunks // otherwise there is a risk file and chunks are not compatible if (!savedChunks) { try { saveChunks(chunkSize); } catch (IOException ioe) { throw new MongoException("couldn't save chunks", ioe); } } super.save(); }