|
@ -9,13 +9,11 @@ import com.yihu.hos.core.file.FileUtil;
|
|
|
import eu.medsea.mimeutil.MimeUtil;
|
|
|
import org.bson.Document;
|
|
|
import org.bson.types.ObjectId;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.mongodb.core.query.Query;
|
|
|
import org.springframework.data.mongodb.gridfs.GridFsCriteria;
|
|
|
import org.springframework.data.mongodb.gridfs.GridFsOperations;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import java.io.*;
|
|
|
import java.sql.Blob;
|
|
|
import java.util.*;
|
|
@ -32,16 +30,10 @@ public class GridFSUtil {
|
|
|
|
|
|
public static final int defaultChunkSize = 1024 * 1024 * 4;
|
|
|
|
|
|
@Autowired
|
|
|
private GridFsOperations operations;
|
|
|
|
|
|
private static GridFsOperations gridFsOperations;
|
|
|
public static GridFsOperations gridFsOperations;
|
|
|
|
|
|
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
gridFsOperations = this.operations;
|
|
|
}
|
|
|
|
|
|
public static ObjectId uploadFile( Blob blob, String fileType, Map<String, Object> params) {
|
|
|
// String fileName = UUID.randomUUID().toString() + "." + fileType;
|
|
@ -348,7 +340,6 @@ public class GridFSUtil {
|
|
|
/**
|
|
|
* 从 mongodb GridFS 下载文件
|
|
|
*
|
|
|
* @param dbName 数据库名
|
|
|
* @param savePath 文件保存路径
|
|
|
* @param fileName GridFS文件名
|
|
|
* @return
|