Package com.mongodb.gridfs

Examples of com.mongodb.gridfs.GridFSDBFile


            String id = in.getId().toString();
            logger.debug("GridFS in: {}", in);
            logger.debug("Document created with id: {}", id);

            GridFSDBFile out = gridFS.findOne(in.getFilename());
            logger.debug("GridFS from findOne: {}", out);
            out = gridFS.findOne(new ObjectId(id));
            logger.debug("GridFS from findOne: {}", out);
            Assert.assertEquals(out.getId(), in.getId());

            Thread.sleep(wait);
            refreshIndex();

            CountResponse countResponse = getNode().client().count(countRequest(getIndex())).actionGet();
View Full Code Here


            String id = in.getId().toString();
            logger.debug("GridFS in: {}", in);
            logger.debug("Document created with id: {}", id);

            GridFSDBFile out = gridFS.findOne(in.getFilename());
            logger.debug("GridFS from findOne: {}", out);
            out = gridFS.findOne(new ObjectId(id));
            logger.debug("GridFS from findOne: {}", out);
            Assert.assertEquals(out.getId(), in.getId());

            Thread.sleep(wait);
            refreshIndex();

            CountResponse countResponse = getNode().client().count(countRequest(getIndex())).actionGet();
View Full Code Here

            String id = in.getId().toString();
            logger.debug("GridFS in: {}", in);
            logger.debug("Document created with id: {}", id);

            GridFSDBFile out = gridFS.findOne(in.getFilename());
            logger.debug("GridFS from findOne: {}", out);
            out = gridFS.findOne(new ObjectId(id));
            logger.debug("GridFS from findOne: {}", out);
            Assert.assertEquals(out.getId(), in.getId());

            Thread.sleep(wait);
            refreshIndex();

            CountResponse countResponse = getNode().client().count(countRequest(getIndex())).actionGet();
View Full Code Here

            String id = in.getId().toString();
            logger.debug("GridFS in: {}", in);
            logger.debug("Document created with id: {}", id);

            GridFSDBFile out = gridFS.findOne(in.getFilename());
            logger.debug("GridFS from findOne: {}", out);
            out = gridFS.findOne(new ObjectId(id));
            logger.debug("GridFS from findOne: {}", out);
            Assert.assertEquals(out.getId(), in.getId());

            Thread.sleep(wait);
            refreshIndex();

            CountResponse countResponse = getNode().client().count(countRequest(getIndex())).actionGet();
View Full Code Here

    }

    public int readBlob(String blobId, long pos, byte[] buff, int off,
            int length) throws Exception {

        GridFSDBFile f = fs.findOne(new ObjectId(blobId));
        if (f == null) {
            throw new NotFoundException(blobId);
        }
        // todo provide a more efficient implementation
        InputStream in = f.getInputStream();
        try {
            in.skip(pos);
            return in.read(buff, off, length);
        } finally {
            IOUtils.closeQuietly(in);
View Full Code Here

            IOUtils.closeQuietly(in);
        }
    }

    public long getBlobLength(String blobId) throws Exception {
        GridFSDBFile f = fs.findOne(new ObjectId(blobId));
        if (f == null) {
            throw new NotFoundException(blobId);
        }

        return f.getLength();
    }
View Full Code Here

  @Override
  public AttachmentData getAttachment(WaveletName waveletName, String id) {

    String completeAttachmentId = computeCompleteAttachmentId(waveletName, id);
    final GridFSDBFile attachment = getAttachmentGrid().findOne(completeAttachmentId);

    if (attachment == null) {
      return null;
    } else {
      return new AttachmentData() {
        @Override
        public void writeDataTo(OutputStream out) throws IOException {
          attachment.writeTo(out);
        }

        @Override
        public Date getLastModifiedDate() {
          return attachment.getUploadDate();
        }

        @Override
        public long getContentSize() {
          return attachment.getLength();
        }

        @Override
        public InputStream getInputStream() {
          return attachment.getInputStream();
        }
      };
    }
  }
View Full Code Here

    return id.toString();
  }

  @Override
  public void get(String resId, OutputStream os) throws IOException {
    GridFSDBFile dbFile =  gridFsOperations.findOne(
        new Query(GridFsCriteria.where("id").is(resId)));
    if(dbFile!=null){
      dbFile.writeTo(os);
    }
  }
View Full Code Here

TOP

Related Classes of com.mongodb.gridfs.GridFSDBFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.