• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java GridFSUploadOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XmlConfiguration类代码示例发布时间:2022-05-22
下一篇:
Java WorkItem类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap