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


Java GridFSDBFile.getInputStream方法代码示例

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


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

示例1: getBlob

import com.mongodb.gridfs.GridFSDBFile; //导入方法依赖的package包/类
@Override
public InputStream getBlob(CallingContext context, String docPath) {
    GridFS gridFS = getGridFS();
    String lockKey = createLockKey(gridFS, docPath);
    LockHandle lockHandle = grabLock(context, lockKey);
    InputStream retVal = null;
    try {
        GridFSDBFile file = gridFS.findOne(docPath);
        if (file != null) {
            retVal = file.getInputStream();
        }
    } finally {
        releaseLock(context, lockKey, lockHandle);
    }
    return retVal;
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:17,代码来源:GridFSBlobHandler.java

示例2: getAttachment

import com.mongodb.gridfs.GridFSDBFile; //导入方法依赖的package包/类
@Override
public AttachmentData getAttachment(AttachmentId attachmentId) {

  final GridFSDBFile attachment = getAttachmentGrid().findOne(attachmentId.serialise());

  if (attachment == null) {
    return null;
  } else {
    return new AttachmentData() {

      @Override
      public InputStream getInputStream() throws IOException {
        return attachment.getInputStream();
      }

      @Override
      public long getSize() {
        return attachment.getLength();
      }
    };
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:23,代码来源:MongoDbStore.java

示例3: readFile

import com.mongodb.gridfs.GridFSDBFile; //导入方法依赖的package包/类
private boolean readFile(GridFSDBFile dbFile, OutputStream os) throws IOException {
	InputStream is = null;
	try {
		is = dbFile.getInputStream();
		byte data[] = new byte[4096];
		int len = 0;
		while ((len = is.read(data, 0, data.length)) > 0) {
			os.write(data, 0, len);
		}
		return true;
	} finally {
		if (is != null) {
			is.close();
		}
	}
}
 
开发者ID:hulop,项目名称:BLELocalization,代码行数:17,代码来源:MongoService.java

示例4: nextTeiDocument

import com.mongodb.gridfs.GridFSDBFile; //导入方法依赖的package包/类
public TEIFile nextTeiDocument() {
    InputStream teiStream = null;
    TEIFile tei = new TEIFile();
    DBObject obj = cursor.next();
    tei.setRepositoryDocId((String) obj.get("repositoryDocId"));
    tei.setFileName(tei.getRepositoryDocId() + ".tei.xml");
    tei.setDocumentType((String) obj.get("documentType"));
    tei.setAnhalyticsId((String) obj.get("anhalyticsId"));
    tei.setSource((String) obj.get("source"));
    tei.setRepositoryDocVersion((String) obj.get("version"));
    GridFSDBFile binaryfile = gfs.findOne(tei.getFileName());

    tei.setFileType((String) binaryfile.getContentType());
    indexFile++;
    teiStream = binaryfile.getInputStream();
    try {
        tei.setTei(IOUtils.toString(teiStream));
        teiStream.close();
    } catch (IOException ex) {
        logger.error(ex.getMessage(), ex.getCause());
    }
    return tei;
}
 
开发者ID:anHALytics,项目名称:anhalytics-core,代码行数:24,代码来源:MongoFileManager.java

示例5: fetchBlobFromMongo

import com.mongodb.gridfs.GridFSDBFile; //导入方法依赖的package包/类
private int fetchBlobFromMongo() throws Exception {
    GridFSDBFile gridFile = gridFS.findOne(new BasicDBObject("md5", blobId));
    long fileLength = gridFile.getLength();
    long start = blobOffset;
    long end = blobOffset + length;
    if (end > fileLength) {
        end = fileLength;
    }
    length = (int) (end - start);

    if (start < end) {
        InputStream is = gridFile.getInputStream();
        if (blobOffset > 0) {
            IOUtils.skipFully(is, blobOffset);
        }
        IOUtils.readFully(is, buffer, bufferOffset, length);
        is.close();
        return length;
    }
    return -1;
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:22,代码来源:ReadBlobCommandGridFS.java

示例6: readFileFromGridFS

import com.mongodb.gridfs.GridFSDBFile; //导入方法依赖的package包/类
public static byte[] readFileFromGridFS(GridFSDBFile file) {
	InputStream is = file.getInputStream();
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	try {

		byte bytes[] = new byte[BUFFER_SIZE];
		int read = -1;

		while ((read = is.read(bytes)) != -1) {
			baos.write(bytes, 0, read);
		}

		return baos.toByteArray();
	}
	catch (Exception e) {
	}
	return null;
}
 
开发者ID:lumongo,项目名称:lumongo,代码行数:19,代码来源:MongoConstants.java

示例7: fileToAttachmentData

import com.mongodb.gridfs.GridFSDBFile; //导入方法依赖的package包/类
private AttachmentData fileToAttachmentData(final GridFSDBFile attachmant) {
  if (attachmant == null) {
    return null;
  } else {
    return new AttachmentData() {

      @Override
      public InputStream getInputStream() throws IOException {
        return attachmant.getInputStream();
      }

      @Override
      public long getSize() {
        return attachmant.getLength();
      }
    };
  }
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:19,代码来源:MongoDbStore.java

示例8: execute

import com.mongodb.gridfs.GridFSDBFile; //导入方法依赖的package包/类
public String execute() throws IOException {
    String fid = httpServletRequest.getParameter("fid");
    GridFSDBFile gridFSDBFile = boxService.download(fid);
    inputStream = gridFSDBFile.getInputStream();
    filename = gridFSDBFile.getFilename();
    return SUCCESS;
}
 
开发者ID:0x603,项目名称:SixBox,代码行数:8,代码来源:DownloadFile.java

示例9: getFile

import com.mongodb.gridfs.GridFSDBFile; //导入方法依赖的package包/类
public InputStream getFile(String filename) {
    GridFS gridFS = getInstance();
    GridFSDBFile _current = gridFS.findOne(filename);
    if(_current == null) {
        return null;
    }
    return _current.getInputStream();
}
 
开发者ID:javahongxi,项目名称:whatsmars,代码行数:9,代码来源:GridFSClient.java

示例10: getImage

import com.mongodb.gridfs.GridFSDBFile; //导入方法依赖的package包/类
public InputStream getImage(String filename,String path) throws Exception{
    //获取最大边,等比缩放
    if(ImageSizeEnum.valueOfPath(path) == null) {
        return null;
    }

    GridFS gridFS = getInstance();
    GridFSDBFile _current = gridFS.findOne(filename);
    if(_current == null) {
        return null;
    }

    int size = ImageSizeEnum.valueOfPath(path).size;

    int max = (Integer)_current.get("max");//图片的实际尺寸

    InputStream result = null;
    //裁剪
    if(size < max) {
        InputStream inputStream = _current.getInputStream();
        BufferedImage image = ImageIO.read(inputStream);

        inputStream.close();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        BufferedImage thumbnail = Scalr.resize(image, size);//保留最大尺寸
        String format = (String) _current.get("format");
        ImageIO.write(thumbnail, format, bos);
        result = new ByteArrayInputStream(bos.toByteArray());
    } else {
        result = _current.getInputStream();
    }

    return result;
}
 
开发者ID:javahongxi,项目名称:whatsmars,代码行数:35,代码来源:GridFSClient.java

示例11: read

import com.mongodb.gridfs.GridFSDBFile; //导入方法依赖的package包/类
@Override
public byte[] read(String filename) throws IOException {
	GridFSDBFile file = getGridFS().findOne(filename);
	if (file == null) {
		throw new FileNotFoundException(filename);
	}
	InputStream input = file.getInputStream();
	try {
		return IOUtils.toByteArray(input);
	}
	finally {
		input.close();
	}
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:15,代码来源:DfsGridImpl.java

示例12: get

import com.mongodb.gridfs.GridFSDBFile; //导入方法依赖的package包/类
@Override
public T get(String keyText) throws IOException, ClassNotFoundException {
    GridFSDBFile objFile = gridfs.findOne(DigestUtils.sha256Hex(keyText));
    if (objFile == null) {
        return null;
    }
    ObjectInputStream objectInput = new ObjectInputStream(objFile.getInputStream());
    T annotation = (T) objectInput.readObject();
    objectInput.close();
    return annotation;
}
 
开发者ID:oaqa,项目名称:LiveQA,代码行数:12,代码来源:MongoPojoCache.java

示例13: parse

import com.mongodb.gridfs.GridFSDBFile; //导入方法依赖的package包/类
@Override
public void parse(GridFSDBFile input, ParserCallback<String> callback)
    throws IOException {
  final Instant time = new Instant(input.getUploadDate().getTime());
  try (BufferedReader reader =
    new BufferedReader(new InputStreamReader(input.getInputStream()))) {
    for (String line = reader.readLine(); line != null; line = reader.readLine()) {
      callback.output(line, time);
    }
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:12,代码来源:MongoDbGridFSIO.java

示例14: getArtifact

import com.mongodb.gridfs.GridFSDBFile; //导入方法依赖的package包/类
@Override
public Artifact getArtifact(DBKey dbKey, String objectID) {
  Artifact artifact = null;

  GridFS gfs = getGridFS(dbKey);
  BasicDBObject query = new BasicDBObject();
  query.put(ID_FIELD_NAME, new ObjectId(objectID));
  GridFSDBFile file = gfs.findOne(query);
  if (file != null) {
    artifact = new Artifact(file.getInputStream(), file.getContentType());
  }
  return artifact;
}
 
开发者ID:Cognifide,项目名称:aet,代码行数:14,代码来源:ArtifactsDAOMongoDBImpl.java

示例15: getStreamByFilename

import com.mongodb.gridfs.GridFSDBFile; //导入方法依赖的package包/类
@Nullable
private InputStream getStreamByFilename(String fname)
{
    GridFSDBFile file = getGridFsTemplate().findOne(new Query().addCriteria(Criteria.where("filename").is(fname)));

    return file != null ? file.getInputStream() : null;
}
 
开发者ID:d0k1,项目名称:jsflight,代码行数:8,代码来源:MongoDbStorageService.java


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