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


Java GridFSFile类代码示例

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


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

示例1: createDataSetAttachment

import com.mongodb.gridfs.GridFSFile; //导入依赖的package包/类
/**
 * Save the attachment for a data set. 
 * @param metadata The metadata of the attachment.
 * @return The GridFs filename.
 * @throws IOException thrown when the input stream is not closable
 */
public String createDataSetAttachment(MultipartFile multipartFile,
    DataSetAttachmentMetadata metadata) throws IOException {
  try (InputStream in = multipartFile.getInputStream()) {
    String currentUser = SecurityUtils.getCurrentUserLogin();
    metadata.setVersion(0L);
    metadata.setCreatedDate(LocalDateTime.now());
    metadata.setCreatedBy(currentUser);
    metadata.setLastModifiedBy(currentUser);
    metadata.setLastModifiedDate(LocalDateTime.now());
    String filename = buildFileName(metadata);
    String contentType = mimeTypeDetector.detect(multipartFile);
    GridFSFile gridFsFile = this.operations.store(in, 
        filename, contentType, metadata);
    gridFsFile.validate();
    return gridFsFile.getFilename();      
  }
}
 
开发者ID:dzhw,项目名称:metadatamanagement,代码行数:24,代码来源:DataSetAttachmentService.java

示例2: createInstrumentAttachment

import com.mongodb.gridfs.GridFSFile; //导入依赖的package包/类
/**
 * Save the attachment for an instrument. 
 * @param metadata The metadata of the attachment.
 * @return The GridFs filename.
 * @throws IOException thrown when the input stream cannot be closed
 */
public String createInstrumentAttachment(MultipartFile multipartFile, 
    InstrumentAttachmentMetadata metadata) throws IOException {
  try (InputStream in = multipartFile.getInputStream()) {
    String currentUser = SecurityUtils.getCurrentUserLogin();
    metadata.setVersion(0L);
    metadata.setCreatedDate(LocalDateTime.now());
    metadata.setCreatedBy(currentUser);
    metadata.setLastModifiedBy(currentUser);
    metadata.setLastModifiedDate(LocalDateTime.now());
    String contentType = mimeTypeDetector.detect(multipartFile);
    GridFSFile gridFsFile = this.operations.store(in, 
        buildFileName(metadata), contentType, metadata);
    gridFsFile.validate();
    return gridFsFile.getFilename();      
  }
}
 
开发者ID:dzhw,项目名称:metadatamanagement,代码行数:23,代码来源:InstrumentAttachmentService.java

示例3: createSurveyAttachment

import com.mongodb.gridfs.GridFSFile; //导入依赖的package包/类
/**
 * Save the attachment for a survey. 
 * @param metadata The metadata of the attachment.
 * @return The GridFs filename.
 * @throws IOException thrown when the input stream is not closable
 */
public String createSurveyAttachment(MultipartFile multipartFile,
    SurveyAttachmentMetadata metadata) throws IOException {
  try (InputStream in = multipartFile.getInputStream()) {
    String currentUser = SecurityUtils.getCurrentUserLogin();
    metadata.setVersion(0L);
    metadata.setCreatedDate(LocalDateTime.now());
    metadata.setCreatedBy(currentUser);
    metadata.setLastModifiedBy(currentUser);
    metadata.setLastModifiedDate(LocalDateTime.now());
    String contentType = mimeTypeDetector.detect(multipartFile);
    String filename = buildFileName(metadata);
    GridFSFile gridFsFile = this.operations.store(in, 
        filename, contentType, metadata);
    gridFsFile.validate();
    return gridFsFile.getFilename();      
  }
}
 
开发者ID:dzhw,项目名称:metadatamanagement,代码行数:24,代码来源:SurveyAttachmentService.java

示例4: createStudyAttachment

import com.mongodb.gridfs.GridFSFile; //导入依赖的package包/类
/**
 * Save the attachment for a study. 
 * @param metadata The metadata of the attachment.
 * @return The GridFs filename.
 * @throws IOException thrown when the input stream cannot be closed
 */
public String createStudyAttachment(MultipartFile multipartFile,
    StudyAttachmentMetadata metadata) throws IOException {
  try (InputStream in = multipartFile.getInputStream()) {
    String currentUser = SecurityUtils.getCurrentUserLogin();
    metadata.setVersion(0L);
    metadata.setCreatedDate(LocalDateTime.now());
    metadata.setCreatedBy(currentUser);
    metadata.setLastModifiedBy(currentUser);
    metadata.setLastModifiedDate(LocalDateTime.now());
    metadata.generateId();
    String contentType = mimeTypeDetector.detect(multipartFile);
    GridFSFile gridFsFile = this.operations.store(in, 
        StudyAttachmentFilenameBuilder.buildFileName(metadata), contentType, metadata);
    gridFsFile.validate();
    javers.commit(currentUser, metadata);
    return gridFsFile.getFilename();      
  }
}
 
开发者ID:dzhw,项目名称:metadatamanagement,代码行数:25,代码来源:StudyAttachmentService.java

示例5: isDumpToLocal

import com.mongodb.gridfs.GridFSFile; //导入依赖的package包/类
private boolean isDumpToLocal(GridFSFile file, GridFS fs){
	long limit = 0; 
	if(this.sizeToLocal.containsKey(fs.getDB().getName())){
		limit = this.sizeToLocal.get(fs.getDB().getName());
	}else {
		limit = this.sizeToLocal.get("default");
	}
	if(file == null && limit == 0){
		return true;
	}else if(file != null){
		log.debug("Check db limit, file size:" + file.getLength() + ", db:" + limit);
		return file.getLength() > limit;
	}else {
		return false;
	}		
}
 
开发者ID:deonwu,项目名称:hdfs-archiver,代码行数:17,代码来源:HDFSArchiver.java

示例6: saveGlbFile

import com.mongodb.gridfs.GridFSFile; //导入依赖的package包/类
public GridFSFile saveGlbFile(InputStream inputStream, String fileName, int rid, double lon, double lat) {
	DBObject metaData = new BasicDBObject("rid", rid);
	metaData.put(STORE_BIM_TYPE, STORE_GLB_FILE);
	metaData.put("rid", rid);
	metaData.put("lon", lon);
	metaData.put("lat", lat);
	return gridFsTemplate.store(inputStream, fileName, metaData);
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:9,代码来源:MongoGridFs.java

示例7: saveGlbOffline

import com.mongodb.gridfs.GridFSFile; //导入依赖的package包/类
public GridFSFile saveGlbOffline(InputStream inputStream, String fileName, Long id, double lon, double lat) {
	DBObject metaData = new BasicDBObject("offline", true);
	metaData.put("id", id);
	metaData.put(STORE_BIM_TYPE, STORE_GLB_FILE);
	metaData.put("lon", lon);
	metaData.put("lat", lat);
	return gridFsTemplate.store(inputStream, fileName, metaData);
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:9,代码来源:MongoGridFs.java

示例8: upload

import com.mongodb.gridfs.GridFSFile; //导入依赖的package包/类
/**
 * 上传文件
 *
 * @param fileEntity 文件实体
 * @param file       待上传文件
 * @param metaData   文件元数据
 * @throws FileNotFoundException 文件不存在
 */
@Override
public FileEntity upload(FileEntity fileEntity, File file, DBObject metaData) throws FileNotFoundException {
    // Upload to GridFS
    FileInputStream fileStream = new FileInputStream(file);
    GridFSFile uploadFile = gridFsOperations.store(fileStream, fileEntity.getFilename(), metaData);

    // Save entity to MongoDB
    fileEntity.setFileId(uploadFile.getId().toString());
    fileEntity.setUploadTime(Utils.getCurrentTimestamp());
    return fileRepository.save(fileEntity);
}
 
开发者ID:0x603,项目名称:SixBox,代码行数:20,代码来源:BoxServiceImpl.java

示例9: store

import com.mongodb.gridfs.GridFSFile; //导入依赖的package包/类
/**
 * Method to store a file within MongoDB's GridFS.
 * @param inputStream containing the file to store.
 * @param fileName the file name under which the file is to be saved.
 * @param contentType a mime type describing the contents of the file.
 * @return a GridFSDBFile object on which an InputStream can be opened.
 */
public FSFile store(InputStream inputStream, String fileName, String contentType) {
    try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SpringMongoConfig.class)) {
        GridFsOperations gridOperations =
                (GridFsOperations) ctx.getBean("gridFsTemplate");
        GridFSFile file = gridOperations.store(inputStream, fileName, contentType);
        return new FSFile((ObjectId) file.getId(), fileName, contentType, file.getLength());
    }
}
 
开发者ID:Morbrolhc,项目名称:kanbanboard,代码行数:16,代码来源:FileStoreImpl.java

示例10: getMimeType

import com.mongodb.gridfs.GridFSFile; //导入依赖的package包/类
@Override
public String getMimeType() {
    if ((mimeType == null || mimeType.isEmpty()) && getId() != null) {
        MediaAssetService mediaAssetService = app.service(MediaAssetService.class);
        GridFSFile fsFile = mediaAssetService.getGridFsFile(getId());
        if (fsFile != null) {
            mimeType = fsFile.getContentType();
        }
    }
    return mimeType;
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:12,代码来源:DefaultMediaAsset.java

示例11: saveTempFile

import com.mongodb.gridfs.GridFSFile; //导入依赖的package包/类
/**
 * Save the given stream to mongo in a "temp directory" and return the final filename.
 * 
 * @param stream The bytes to save
 * @param fileName The fileName which gets prefixed with /tmp/
 * @param contentType the content type of the file
 * @return the final filename
 * @throws IOException thrown when the input stream cannot be closed
 */
public String saveTempFile(InputStream stream, String fileName, String contentType)
    throws IOException {
  try (InputStream inputStream = stream) {
    GridFSFile gridFsFile = 
        this.gridfOperations.store(inputStream, "/tmp/" + fileName, contentType);
    gridFsFile.validate();
    return gridFsFile.getFilename();      
  }
}
 
开发者ID:dzhw,项目名称:metadatamanagement,代码行数:19,代码来源:FileService.java

示例12: saveQuestionImage

import com.mongodb.gridfs.GridFSFile; //导入依赖的package包/类
/**
 * This method save an image into GridFS/MongoDB based on a byteArrayOutputStream.
 * Existing image should be deleted before saving/updating an image
 * @param questionId The id of the question to be saved
 * @return return the name of the saved image in the GridFS / MongoDB.
 * @throws IOException Thrown when the input stream cannot be closed
 */
public String saveQuestionImage(MultipartFile multipartFile,
    String questionId) throws IOException {
  try (InputStream in = multipartFile.getInputStream()) {
    String contentType = mimeTypeDetector.detect(multipartFile);
    GridFSFile gridFsFile = this.operations.store(in, 
        "/questions/" + questionId, contentType);
    gridFsFile.validate();
    return gridFsFile.getFilename();      
  }
}
 
开发者ID:dzhw,项目名称:metadatamanagement,代码行数:18,代码来源:QuestionImageService.java

示例13: saveSurveyImage

import com.mongodb.gridfs.GridFSFile; //导入依赖的package包/类
/**
 * This method save an image into GridFS/MongoDB based on a byteArrayOutputStream.
 * Existing image should be deleted before saving/updating an image
 * @param surveyId The id of the question to be saved
 * @return return the name of the saved image in the GridFS / MongoDB.
 * @throws IOException thrown if the input stream cannot be closed
 */
public String saveSurveyImage(MultipartFile multipartFile,
    String surveyId, String fileName) throws IOException {
  try (InputStream in = multipartFile.getInputStream()) {
    String relativePathWithName = "/surveys/" + surveyId + "/" + fileName;
    String contentType = mimeTypeDetector.detect(multipartFile);
    GridFSFile gridFsFile = this.operations.store(in, relativePathWithName, contentType);
    gridFsFile.validate();
    
    return gridFsFile.getFilename();      
  }
}
 
开发者ID:dzhw,项目名称:metadatamanagement,代码行数:19,代码来源:SurveyResponseRateImageService.java

示例14: addPage

import com.mongodb.gridfs.GridFSFile; //导入依赖的package包/类
@Override
public Book addPage(String bookId, Page page) {
    Book readBook = readBook(bookId,INVALID_PAGINATION_PARAMITER,INVALID_PAGINATION_PARAMITER);
    GridFSFile store = gridFsTemplate.store(new ByteArrayInputStream(page.getBytes()), page.getFileName());
    Book book = BookBuilder.newBookBuilder(readBook).addPage(fileNameToindex(page), String.valueOf(store.getId())).build();

    mongoTemplate.save(book);
    return book;
}
 
开发者ID:mrFlick72,项目名称:socialDocumentLibrary,代码行数:10,代码来源:BookRepositoryMongoImpl.java

示例15: MongoRepositoryItem

import com.mongodb.gridfs.GridFSFile; //导入依赖的package包/类
private MongoRepositoryItem(MongoRepository repository, GridFSFile dbFile, State state) {

    super(dbFile.getId().toString(), state, loadAttributes(dbFile), repository);

    this.dbFile = dbFile;
    // don't call ours setMetadata(...)
    super.setMetadata(new HashMap<String, String>());
  }
 
开发者ID:Kurento,项目名称:kurento-java,代码行数:9,代码来源:MongoRepositoryItem.java


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