byte[] data = new byte[1024]; try (InputStream stream = file.getInputStream()) { while ((nRead = stream.read(data, 0, data.length)) != -1) { buffer.write(data, 0, nRead);
md5.reset(); int read = 0; DigestInputStream is = new DigestInputStream(f.getInputStream(), md5); try { while (is.read() >= 0) {
@Override public InputStream getInputStream() throws IOException { return resource.getInputStream(); } });
@Override public InputStream getInputStream() throws IOException { return resource.getInputStream(); } });
@Override public InputStream getInputStream() throws IOException { return resource.getInputStream(); } }, -1);
InputStream is = outputFile.getInputStream(); try
GridFSDBFile gfsFileOut = (GridFSDBFile) gridfs.findOne(rawName); System.out.println(gfsFileOut.getInputStream()); InputStream is = gfsFileOut.getInputStream(); // Reading the excel file List<String> list = null; BufferedReader br = null; try { String sCurrentLine; br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
/** * Read data from the GridFS chunk represented by this split. * @return The decoded data from the chunk * @throws IOException if there is an exception reading the data. */ public InputStream getData() throws IOException { InputStream fileStream = getFile().getInputStream(); // Skip to chunk. GridFSInputStream will do what we want here. // noinspection ResultOfMethodCallIgnored fileStream.skip(chunkSize * chunkId); return fileStream; }
@Override public InputStream getInputStream(String contentFileId) { GridFSDBFile fsFile = getGridFSDBFile(contentFileId); return fsFile.getInputStream(); }
@Override public InputStream createInputStreamToRead() { checkState(State.STORED); return ((GridFSDBFile) dbFile).getInputStream(); }
@Override public InputStream createInputStreamToRead() { checkState(State.STORED); return ((GridFSDBFile) dbFile).getInputStream(); }
@RequestMapping(value = "/image", method = RequestMethod.GET) @ResponseBody public ResponseEntity<InputStreamResource> getImage() { GridFSDBFile gridFsFile = App.getImageResponse(); return ResponseEntity.ok() .contentLength(gridFsFile.getLength()) .contentType(MediaType.parseMediaType(gridFsFile.getContentType())) .body(new InputStreamResource(gridFsFile.getInputStream())); }
@Override public InputStream getInputStream() { if(getFile() == null){ return new ByteArrayInputStream(new byte[0]); } return getFile().getInputStream(); }
@Override public InputStream getStream(DatabaseFile df) { GridFSDBFile file = pipelinefs.findOne(new BasicDBObject(MongoDocument.MONGO_ID_KEY, df.getId())); return file==null ? null : file.getInputStream(); }
@Override public List<BinaryData> findByFilename(String filename) { return gridFs.find(findByFilenameQuery(filename)).stream() .map(file -> new BinaryData(file.getContentType(), file.getLength(), file.getInputStream())) .collect(Collectors.toList()); }
private InputStream getOriginalInputStream(){ DBObject query = new BasicDBObject(BuguFS.FILENAME, filename); query.put(DIMENSION, null); BuguFS fs = BuguFSFactory.getInstance().create(connection, bucket, chunkSize); GridFSDBFile f = fs.findOne(query); return f.getInputStream(); }
@Override public AttachmentMetadata getMetadata(AttachmentId attachmentId) throws IOException { final GridFSDBFile metadata = metadataGrid.findOne(attachmentId.serialise()); if (metadata == null) { return null; } AttachmentProto.AttachmentMetadata protoMetadata = AttachmentProto.AttachmentMetadata.parseFrom(metadata.getInputStream()); return new AttachmentMetadataProtoImpl(protoMetadata); }
@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; }
@Override public BinaryData fetchData(String dataId) { GridFSDBFile file = gridFs.findOne(findByIdQuery(new ObjectId(dataId))); return null == file ? null : new BinaryData(file.getContentType(), file.getLength(), file.getInputStream()); }
@Override public Blob apply(GridFSDBFile input) { MutableBlobMetadata blobMetadata = dbFileToBlobMetadata.apply(input); Payload payload = Payloads.newInputStreamPayload(input.getInputStream()); payload.setContentMetadata(blobMetadata.getContentMetadata()); Blob blob = blobFactory.create(blobMetadata); blob.setPayload(payload); return blob; } }