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


Java GridFSFile.validate方法代码示例

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


在下文中一共展示了GridFSFile.validate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例6: 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

示例7: 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


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