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 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()); }
@Override public void putBlobStream(BucketPath bucketPath, PayloadStream payloadStream) { LOGGER.debug("start putBlobStream for " + bucketPath); GridFSBucket bucket = getGridFSBucket(bucketPath); checkBucketExists(bucket); String filename = bucketPath.getObjectHandle().getName(); GridFSUploadOptions uploadOptions = new GridFSUploadOptions(); uploadOptions.metadata(new Document()); SimpleStorageMetadataImpl storageMetadata = new SimpleStorageMetadataImpl(payloadStream.getStorageMetadata()); storageMetadata.setType(StorageType.BLOB); storageMetadata.setName(BucketPathUtil.getAsString(bucketPath)); uploadOptions.getMetadata().put(STORAGE_METADATA_KEY, gsonHelper.toJson(storageMetadata)); InputStream is = payloadStream.openStream(); ObjectId objectId = bucket.uploadFromStream(filename, is, uploadOptions); IOUtils.closeQuietly(is); deleteAllExcept(bucket, filename, objectId); LOGGER.debug("finished putBlobStream for " + bucketPath); }