private GridFSUploadStream createGridFSUploadStream(@Nullable final ClientSession clientSession, final BsonValue id, final String filename, final GridFSUploadOptions options) { notNull("options", options); Integer chunkSizeBytes = options.getChunkSizeBytes(); int chunkSize = chunkSizeBytes == null ? this.chunkSizeBytes : chunkSizeBytes; checkCreateIndex(clientSession); return new GridFSUploadStreamImpl(clientSession, filesCollection, chunksCollection, id, filename, chunkSize, disableMD5, options.getMetadata()); }
private void executeUploadFromStream(@Nullable final ClientSession clientSession, final BsonValue id, final String filename, final InputStream source, final GridFSUploadOptions options) { GridFSUploadStream uploadStream = createGridFSUploadStream(clientSession, id, filename, options); Integer chunkSizeBytes = options.getChunkSizeBytes(); int chunkSize = chunkSizeBytes == null ? this.chunkSizeBytes : chunkSizeBytes; byte[] buffer = new byte[chunkSize]; int len; try { while ((len = source.read(buffer)) != -1) { uploadStream.write(buffer, 0, len); } uploadStream.close(); } catch (IOException e) { uploadStream.abort(); throw new MongoGridFSException("IOException when reading from the InputStream", e); } }
private GridFSUploadStream createGridFSUploadStream(@Nullable final ClientSession clientSession, final BsonValue id, final String filename, final GridFSUploadOptions options) { notNull("options", options); Integer chunkSizeBytes = options.getChunkSizeBytes(); int chunkSize = chunkSizeBytes == null ? this.chunkSizeBytes : chunkSizeBytes; checkCreateIndex(clientSession); return new GridFSUploadStreamImpl(clientSession, filesCollection, chunksCollection, id, filename, chunkSize, disableMD5, options.getMetadata()); }
private GridFSUploadStream createGridFSUploadStream(@Nullable final ClientSession clientSession, final BsonValue id, final String filename, final GridFSUploadOptions options) { notNull("options", options); Integer chunkSizeBytes = options.getChunkSizeBytes(); int chunkSize = chunkSizeBytes == null ? this.chunkSizeBytes : chunkSizeBytes; checkCreateIndex(clientSession); return new GridFSUploadStreamImpl(clientSession, filesCollection, chunksCollection, id, filename, chunkSize, disableMD5, options.getMetadata()); }
private void executeUploadFromStream(@Nullable final ClientSession clientSession, final BsonValue id, final String filename, final InputStream source, final GridFSUploadOptions options) { GridFSUploadStream uploadStream = createGridFSUploadStream(clientSession, id, filename, options); Integer chunkSizeBytes = options.getChunkSizeBytes(); int chunkSize = chunkSizeBytes == null ? this.chunkSizeBytes : chunkSizeBytes; byte[] buffer = new byte[chunkSize]; int len; try { while ((len = source.read(buffer)) != -1) { uploadStream.write(buffer, 0, len); } uploadStream.close(); } catch (IOException e) { uploadStream.abort(); throw new MongoGridFSException("IOException when reading from the InputStream", e); } }
private void executeUploadFromStream(@Nullable final ClientSession clientSession, final BsonValue id, final String filename, final InputStream source, final GridFSUploadOptions options) { GridFSUploadStream uploadStream = createGridFSUploadStream(clientSession, id, filename, options); Integer chunkSizeBytes = options.getChunkSizeBytes(); int chunkSize = chunkSizeBytes == null ? this.chunkSizeBytes : chunkSizeBytes; byte[] buffer = new byte[chunkSize]; int len; try { while ((len = source.read(buffer)) != -1) { uploadStream.write(buffer, 0, len); } uploadStream.close(); } catch (IOException e) { uploadStream.abort(); throw new MongoGridFSException("IOException when reading from the InputStream", e); } }