當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。