当前位置: 首页>>代码示例>>Java>>正文


Java GridFSUploadOptions类代码示例

本文整理汇总了Java中com.mongodb.client.gridfs.model.GridFSUploadOptions的典型用法代码示例。如果您正苦于以下问题:Java GridFSUploadOptions类的具体用法?Java GridFSUploadOptions怎么用?Java GridFSUploadOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GridFSUploadOptions类属于com.mongodb.client.gridfs.model包,在下文中一共展示了GridFSUploadOptions类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: putBlob

import com.mongodb.client.gridfs.model.GridFSUploadOptions; //导入依赖的package包/类
@Override
public Uri putBlob(Uri uri, Blob blob) {
	GridFSUploadOptions options = new GridFSUploadOptions();

	Document document = JsonBsonCodec.toBson(mapper, blob.getMetadata());
	options.metadata(document);

	GridFSUploadStream file = bucket.openUploadStream(uri.toString(), options);
	try {
		IOUtils.copy(blob.getPayload().openStream(), file);
	} catch (IOException e) {
		throw Throwables.propagate(e);
	}
	file.close();

	return Uri.create("mongodb://" + databaseName + "/" + bucket.getBucketName() + "/" + file.getFileId().toString());
}
 
开发者ID:Treydone,项目名称:mandrel,代码行数:18,代码来源:MongoBlobStore.java

示例2: store

import com.mongodb.client.gridfs.model.GridFSUploadOptions; //导入依赖的package包/类
@Override
public InputStream store(DownloadItem downloadItem) throws IOException, JSONException {
	rwl.r.lock();
	try {
		final URI uri = downloadItem.getUri();
		if (!uri.equals(this.uri))
			throw new IOException("The URI does not match: " + uri + " / " + this.uri);

		final Document newDocument = Document.parse(downloadItem.getMetaAsJson());
		newDocument.put("uri", uriString);

		final BsonValue id = metaCollection.replaceOne(eq("uri", uriString), newDocument, UPSERT)
				.getUpsertedId();

		final GridFSUploadOptions options = new GridFSUploadOptions().metadata(new Document("_id", id));

		contentGrid.uploadFromStream(id, uriString, downloadItem.getContentInputStream(), options);

		return contentGrid.openDownloadStream(id);
	} finally {
		rwl.r.unlock();
	}
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:24,代码来源:MongoDbCrawlCache.java

示例3: uploadStream

import com.mongodb.client.gridfs.model.GridFSUploadOptions; //导入依赖的package包/类
private void uploadStream(SmofGridRef ref, String name, InputStream stream) {
	final String bucketName = ref.getBucketName();
	final ObjectId id;
	final GridFSBucket bucket;
	Preconditions.checkNotNull(bucketName, "No bucket specified");
	final GridFSUploadOptions options = new GridFSUploadOptions().metadata(ref.getMetadata());
	bucket = pool.getBucket(bucketName);
	id = bucket.uploadFromStream(name, stream, options);
	ref.setId(id);
}
 
开发者ID:JPDSousa,项目名称:mongo-obj-framework,代码行数:11,代码来源:SmofGridStreamManagerImpl.java

示例4: uploadFromStream

import com.mongodb.client.gridfs.model.GridFSUploadOptions; //导入依赖的package包/类
@Override
public Observable<ObjectId> uploadFromStream(final String filename, final AsyncInputStream source, final GridFSUploadOptions options) {
    return RxObservables.create(Observables.observe(new Block<SingleResultCallback<ObjectId>>() {
        @Override
        public void apply(final SingleResultCallback<ObjectId> callback) {
            wrapped.uploadFromStream(filename, toCallbackAsyncInputStream(source), options, callback);
        }
    }), observableAdapter);
}
 
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:10,代码来源:GridFSBucketImpl.java

示例5: uploadFromStream

import com.mongodb.client.gridfs.model.GridFSUploadOptions; //导入依赖的package包/类
@Override
public Publisher<ObjectId> uploadFromStream(final String filename, final AsyncInputStream source, final GridFSUploadOptions options) {
    return new ObservableToPublisher<ObjectId>(observe(new Block<SingleResultCallback<ObjectId>>() {
        @Override
        public void apply(final SingleResultCallback<ObjectId> callback) {
            wrapped.uploadFromStream(filename, toCallbackAsyncInputStream(source), options, callback);
        }
    }));
}
 
开发者ID:mongodb,项目名称:mongo-java-driver-reactivestreams,代码行数:10,代码来源:GridFSBucketImpl.java

示例6: getGridFSUploadOptions

import com.mongodb.client.gridfs.model.GridFSUploadOptions; //导入依赖的package包/类
private GridFSUploadOptions getGridFSUploadOptions(String uniqueId, String fileName, boolean compress, long timestamp, Map<String, String> metadataMap) {
	Document metadata = new Document();
	if (metadataMap != null) {
		for (String key : metadataMap.keySet()) {
			metadata.put(key, metadataMap.get(key));
		}
	}
	metadata.put(TIMESTAMP, timestamp);
	metadata.put(COMPRESSED_FLAG, compress);
	metadata.put(DOCUMENT_UNIQUE_ID_KEY, uniqueId);
	metadata.put(FILE_UNIQUE_ID_KEY, getGridFsId(uniqueId, fileName));

	return new GridFSUploadOptions().chunkSizeBytes(1024).metadata(metadata);
}
 
开发者ID:lumongo,项目名称:lumongo,代码行数:15,代码来源:MongoDocumentStorage.java

示例7: FileStoreBucket

import com.mongodb.client.gridfs.model.GridFSUploadOptions; //导入依赖的package包/类
public FileStoreBucket() {
	gridFSUploadOptions = new GridFSUploadOptions();
	gridFSUploadOptions.chunkSizeBytes(CHUNK_SIZE_BYTES);
}
 
开发者ID:ccem-dev,项目名称:otus-api,代码行数:5,代码来源:FileStoreBucket.java

示例8: openUploadStream

import com.mongodb.client.gridfs.model.GridFSUploadOptions; //导入依赖的package包/类
@Override
public GridFSUploadStream openUploadStream(final BsonValue id, final String filename, final GridFSUploadOptions options) {
    return new GridFSUploadStreamImpl(wrapped.openUploadStream(id, filename, options), observableAdapter);
}
 
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:5,代码来源:GridFSBucketImpl.java

示例9: openUploadStream

import com.mongodb.client.gridfs.model.GridFSUploadOptions; //导入依赖的package包/类
@Override
public GridFSUploadStream openUploadStream(final String filename) {
    return openUploadStream(filename, new GridFSUploadOptions());
}
 
开发者ID:mongodb,项目名称:mongo-java-driver-reactivestreams,代码行数:5,代码来源:GridFSBucketImpl.java

示例10: openUploadStream

import com.mongodb.client.gridfs.model.GridFSUploadOptions; //导入依赖的package包/类
/**
 * Opens a AsyncOutputStream that the application can write the contents of the file to.
 * <p>
 * As the application writes the contents to the returned Stream, the contents are uploaded as chunks in the chunks collection. When
 * the application signals it is done writing the contents of the file by calling close on the returned Stream, a files collection
 * document is created in the files collection.
 * </p>
 *
 * @param filename the filename for the stream
 * @param options  the GridFSUploadOptions
 * @return the GridFSUploadStream that provides the ObjectId for the file to be uploaded and the Stream to which the
 * application will write the contents.
 */
GridFSUploadStream openUploadStream(String filename, GridFSUploadOptions options);
 
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:15,代码来源:GridFSBucket.java

示例11: uploadFromStream

import com.mongodb.client.gridfs.model.GridFSUploadOptions; //导入依赖的package包/类
/**
 * Uploads the contents of the given {@code AsyncInputStream} to a GridFS bucket.
 * <p>
 * Reads the contents of the user file from the {@code source} and uploads it as chunks in the chunks collection. After all the
 * chunks have been uploaded, it creates a files collection document for {@code filename} in the files collection.
 * </p>
 *
 * @param filename the filename for the stream
 * @param source   the Stream providing the file data
 * @param options  the GridFSUploadOptions
 * @return an observable with a single element, the ObjectId of the uploaded file.
 */
Observable<ObjectId> uploadFromStream(String filename, AsyncInputStream source, GridFSUploadOptions options);
 
开发者ID:mongodb,项目名称:mongo-java-driver-rx,代码行数:14,代码来源:GridFSBucket.java

示例12: uploadFromStream

import com.mongodb.client.gridfs.model.GridFSUploadOptions; //导入依赖的package包/类
/**
 * Uploads the contents of the given {@code AsyncInputStream} to a GridFS bucket.
 * <p>
 * Reads the contents of the user file from the {@code source} and uploads it as chunks in the chunks collection. After all the
 * chunks have been uploaded, it creates a files collection document for {@code filename} in the files collection.
 * </p>
 *
 * @param filename the filename for the stream
 * @param source   the Stream providing the file data
 * @param options  the GridFSUploadOptions
 * @return a publisher with a single element, the ObjectId of the uploaded file.
 */
Publisher<ObjectId> uploadFromStream(String filename, AsyncInputStream source, GridFSUploadOptions options);
 
开发者ID:mongodb,项目名称:mongo-java-driver-reactivestreams,代码行数:14,代码来源:GridFSBucket.java


注:本文中的com.mongodb.client.gridfs.model.GridFSUploadOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。