Package com.mongodb.gridfs

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


            if (cacheWriteEnable) {

                final GridFSInputFile gfsFile = MongoConnectionHelper.getGridFS().createFile(f);
                gfsFile.setFilename(f.getName());
                gfsFile.save();

                final Cache c = new Cache();
                c.setServletName(this.getClass().getName());
                c.setCacheKey(cacheKey);
                c.setGridId(gfsFile.getId().toString());
View Full Code Here


        try {

            if (cacheWriteEnable) {
                final GridFSInputFile gfsFile = MongoConnectionHelper.getGridFS().createFile(f);
                gfsFile.setFilename(f.getName());
                gfsFile.save();

                final Cache c = new Cache();
                c.setServletName(this.getClass().getName());
                c.setCacheKey(cacheKey);
                c.setGridId(gfsFile.getId().toString());
View Full Code Here

    if (contentType != null) {
      file.setContentType(contentType);
    }

    file.save();
    return file;
  }

  /*
   * (non-Javadoc)
 
View Full Code Here

    GridFSInputFile input = documentfs.createFile(df.getStream(), df.getFileName());
    input.put(DOCUMENT_KEY, df.getDocumentId().getID());
    input.put(ENCODING_KEY, df.getEncoding());
    input.put(MIMETYPE_KEY, df.getMimetype());
   
    input.save();
   
    /**
     * This is here because of random failures when trying to do this query from another thread.
     *
     * RemotePipelineTest.testSaveFile() failed 2 or 3 times out of 100.
View Full Code Here

  }
 
  @Override
  public Object save(String fileName, InputStream file) {
    GridFSInputFile inputFile = pipelinefs.createFile(file, fileName);
    inputFile.save();
    return inputFile.getId();
  }
 
  @Override
  public boolean save(Object id, String fileName, InputStream file) {
View Full Code Here

  public boolean save(Object id, String fileName, InputStream file) {
    pipelinefs.remove(new BasicDBObject(MongoDocument.MONGO_ID_KEY, id));
   
    GridFSInputFile inputFile = pipelinefs.createFile(file, fileName);
    inputFile.put("_id", id);
    inputFile.save();
    return true;
  }

  @Override
  public boolean deleteFile(Object id) {
View Full Code Here

                (byte) 0xCA,
                (byte) 0xFE,
                (byte) 0xBA,
                (byte) 0xBE});
        gridFile.setFilename("test.txt");
        gridFile.save();
    }

    private void queryWithJongoAndMapToCustomClass() {
        CustomFileDescriptor descriptor = getJongo().getCollection("fs.files")
                .findOne()
View Full Code Here

            is.close();
            return md5;
        }

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

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

            Logger.warn("File not exists: %s", file);
            return;
        }
        GridFSInputFile inputFile = MorphiaPlugin.gridFs().createFile(file);
        inputFile.setContentType(type);
        inputFile.save();
        this.file = MorphiaPlugin.gridFs().findOne(new ObjectId(inputFile.getId().toString()));
    }
   

    @Override
View Full Code Here

    public void set(InputStream is, String type) {
        String rand = RandomStringUtils.randomAlphanumeric(10);
        GridFSInputFile inputFile = MorphiaPlugin.gridFs().createFile(is);
        inputFile.setContentType(type);
        inputFile.put("name", rand);
        inputFile.save();
        file = MorphiaPlugin.gridFs().findOne(new ObjectId(inputFile.getId().toString()));
    }

    @Override
    public long length() {
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.