Package com.mongodb.gridfs

Examples of com.mongodb.gridfs.GridFSInputFile.save()


            is.close();
            return md5;
        }

        GridFSInputFile gridFSInputFile = gridFS.createFile(bis, true);
        gridFSInputFile.save();
        return gridFSInputFile.getMD5();
    }

    private String calculateMd5(BufferedInputStream bis) throws IOException {
        bis.mark(Integer.MAX_VALUE);
View Full Code Here


        for (int i = 0; i < count; i++) {

            GridFSInputFile in = gridFS.createFile(content);
            in.setFilename("lorem-" + i + ".pdf");
            in.setContentType("application/pdf");
            in.save();
            in.validate();

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

            logger.debug("Content in bytes: {}", content.length);
            GridFS gridFS = new GridFS(mongoDB);
            GridFSInputFile in = gridFS.createFile(content);
            in.setFilename("test-attachment.html");
            in.setContentType("text/html");
            in.save();
            in.validate();

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

            assertThat(totalHits, equalTo(1l));

            in = gridFS.createFile(content);
            in.setFilename("test-attachment-2.html");
            in.setContentType("text/html");
            in.save();
            in.validate();

            id = in.getId().toString();

            out = gridFS.findOne(in.getFilename());
View Full Code Here

            logger.debug("Content in bytes: {}", content.length);
            GridFS gridFS = new GridFS(mongoDB, getCollection());
            GridFSInputFile in = gridFS.createFile(content);
            in.setFilename("test-attachment.html");
            in.setContentType("text/html");
            in.save();
            in.validate();

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

            logger.debug("Content in bytes: {}", content.length);
            GridFS gridFS = new GridFS(mongoDB);
            GridFSInputFile in = gridFS.createFile(content);
            in.setFilename("test-attachment.html");
            in.setContentType("text/html");
            in.save();
            in.validate();

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

            logger.debug("Content in bytes: {}", content.length);
            GridFS gridFS = new GridFS(mongoDB);
            GridFSInputFile in = gridFS.createFile(content);
            in.setFilename("lorem.pdf");
            in.setContentType("application/pdf");
            in.save();
            in.validate();

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

            in.setContentType("text/html");
            BasicDBObject metadata = new BasicDBObject();
            metadata.put("attribut1", "value1");
            metadata.put("attribut2", "value2");
            in.put("metadata", metadata);
            in.save();
            in.validate();

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

    }

    public String writeBlob(InputStream in) throws Exception {
        GridFSInputFile f = fs.createFile(in, true);
        //f.save(0x20000);   // save in 128k chunks
        f.save();

        return f.getId().toString();
    }

    public int readBlob(String blobId, long pos, byte[] buff, int off,
View Full Code Here

    } else {
      String completeAttachmentId = computeCompleteAttachmentId(waveletName, id);
      GridFSInputFile file = getAttachmentGrid().createFile(data, completeAttachmentId);

      try {
        file.save();
      } catch (MongoException e) {
        // Unfortunately, file.save() wraps any IOException thrown in a
        // 'MongoException'. Since the interface explicitly throws IOExceptions,
        // we unwrap any IOExceptions thrown.
        Throwable innerException = e.getCause();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.