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


Java GridFSDBFile.containsField方法代码示例

本文整理汇总了Java中com.mongodb.gridfs.GridFSDBFile.containsField方法的典型用法代码示例。如果您正苦于以下问题:Java GridFSDBFile.containsField方法的具体用法?Java GridFSDBFile.containsField怎么用?Java GridFSDBFile.containsField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mongodb.gridfs.GridFSDBFile的用法示例。


在下文中一共展示了GridFSDBFile.containsField方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFile

import com.mongodb.gridfs.GridFSDBFile; //导入方法依赖的package包/类
public GridFSDBFile getFile(String path){
	if(!this.isConnected()) return null;
	GridFSDBFile file = null;
	if(path.indexOf('$') > 0){
		String[] t = path.split("\\$", 2);
		file = getGridFS(t[0]).findOne(t[1]);
	}else{
		file = defaultFs.findOne(path);
	}
	if(file != null && file.containsField("localLength")){
		file.put("localPath", new File(this.rootPath, file.getFilename()).getAbsolutePath());
		file.put("length", (Long)file.get("localLength"));
	}
	return file;
}
 
开发者ID:deonwu,项目名称:hdfs-archiver,代码行数:16,代码来源:HDFSArchiver.java

示例2: serveFile

import com.mongodb.gridfs.GridFSDBFile; //导入方法依赖的package包/类
private void serveFile(String path, 
		HttpServletRequest request,
		HttpServletResponse response) throws IOException{
	
	GridFSDBFile file = HDFSArchiver.getArchiver().getFile(path);
	if(file != null){
		String content = null;
		if(request.getParameter("download") == null){
			content = file.getContentType();
		}else {
			content = "application/octet-stream";
		}
		if(content == null){
			content = getContentType(path);
		}
		response.setContentType(content);
		log.debug("Response file:" + path + ", content:" + content);
		if(file.containsField("localPath")){
			log.debug("local from local path:" + file.get("localPath"));
			byte[] buffer = new byte[1024 * 40];
			InputStream in = new FileInputStream(new File(file.get("localPath").toString()));
			for(int len = buffer.length; len == buffer.length; ){
				len = in.read(buffer);
				response.getOutputStream().write(buffer, 0, len);
			}
			in.close();
		}else {
			file.writeTo(response.getOutputStream());
		}
	}else {
		log.debug("Not found file:" + path);
		response.setStatus(HttpServletResponse.SC_NOT_FOUND);
		response.getWriter().write("Not found file:" + path);
	}
}
 
开发者ID:deonwu,项目名称:hdfs-archiver,代码行数:36,代码来源:DirectoryList.java

示例3: getBlob

import com.mongodb.gridfs.GridFSDBFile; //导入方法依赖的package包/类
@Override
public ByteArrayFileCache getBlob(final MD5 md5,
		final ByteArrayFileCacheManager bafcMan)
		throws NoSuchBlobException, BlobStoreCommunicationException,
		FileCacheIOException, FileCacheLimitExceededException {
	final GridFSDBFile out;
	try {
		out = getFile(md5);
		if (out == null) {
			throw new NoSuchBlobException(
					"Attempt to retrieve non-existant blob with chksum " + 
							md5.getMD5());
		}
		final boolean sorted;
		if (!out.containsField(Fields.GFS_SORTED)) {
			sorted = false;
		} else {
			sorted = (Boolean)out.get(Fields.GFS_SORTED);
		}
		final InputStream file = out.getInputStream();
		try {
			return bafcMan.createBAFC(file, true, sorted);
		} finally {
			try {
				file.close();
			} catch (IOException ioe) {
				throw new RuntimeException("Something is broken", ioe);
			}
		}	
	} catch (MongoException me) {
		throw new BlobStoreCommunicationException(
				"Could not read from the mongo database", me);
	}
}
 
开发者ID:kbase,项目名称:workspace_deluxe,代码行数:35,代码来源:GridFSBlobStore.java


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