cy 2 лет назад
Родитель
Сommit
d7d5061135

+ 39 - 24
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/UploadFileController.java

@@ -1,13 +1,16 @@
 package com.yonge.cooleshow.admin.controller;
 
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiParam;
+import com.ksyun.ks3.dto.PostObjectFormFields;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.toolset.thirdparty.entity.UploadSign;
+import io.swagger.annotations.*;
 
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
@@ -17,32 +20,44 @@ import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.UploadReturnBean;
 import com.yonge.toolset.utils.upload.UploadUtil;
 
-/** 
+/**
  * 上传控制层
  */
 @RestController
 @Api(tags = "文件上传服务")
 public class UploadFileController extends BaseController {
 
-	private final static Logger LOGGER = LoggerFactory.getLogger(UploadFileController.class);
-
-	@Autowired
-	private UploadFileService uploadFileService;
-
-	@PostMapping(value = "uploadFile")
-	public Object uploadFile(@ApiParam(value = "上传的文件", required = true) @RequestParam("file") MultipartFile file) {
-		try {
-			if (file != null && StringUtils.isNotBlank(file.getOriginalFilename())) {
-				UploadReturnBean bean = uploadFileService.uploadFile(file.getInputStream(), UploadUtil.getExtension(file.getOriginalFilename()));
-				bean.setName(file.getOriginalFilename());
-				if (bean.isStatus()) {
-					return succeed(bean);
-				}
-				return failed(bean.getMessage());
-			}
-		} catch (Exception e) {
-			LOGGER.error("上传失败", e);
-		}
-		return failed("上传失败");
-	}
+    private final static Logger LOGGER = LoggerFactory.getLogger(UploadFileController.class);
+
+    @Autowired
+    private UploadFileService uploadFileService;
+
+    @PostMapping(value = "uploadFile")
+    public Object uploadFile(@ApiParam(value = "上传的文件", required = true) @RequestParam("file") MultipartFile file) {
+        try {
+            if (file != null && StringUtils.isNotBlank(file.getOriginalFilename())) {
+                UploadReturnBean bean = uploadFileService.uploadFile(file.getInputStream(), UploadUtil.getExtension(file.getOriginalFilename()));
+                bean.setName(file.getOriginalFilename());
+                if (bean.isStatus()) {
+                    return succeed(bean);
+                }
+                return failed(bean.getMessage());
+            }
+        } catch (Exception e) {
+            LOGGER.error("上传失败", e);
+        }
+        return failed("上传失败");
+    }
+
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "fileName", dataType = "String", value = "要上传的文件名称,不包含路径信息"),
+            @ApiImplicitParam(name = "postData", dataType = "Map", value = "1.如果使用js sdk上传的时候设置了ACL请设置,例\"acl\":\"public-read\"值要与SDK中一致,没有则删除该项</br>" +
+                    "2.提供js sdk中的key值,例\"key\":\"20150115/中文/${filename}\""),
+            @ApiImplicitParam(name = "unknowValueField", dataType = "List", value = "对于用户无法确定表单值的放在unknownValueField中(比如有的上传控件会添加一些表单项,但表单项的值可能是随机的)"),
+    })
+    @ApiOperation("获取上传文件签名")
+    @PostMapping("/getUploadSign")
+    public HttpResponseResult<PostObjectFormFields> getUploadSign(@RequestBody UploadSign uploadSign) {
+        return succeed(uploadFileService.getUploadSign(uploadSign));
+    }
 }

+ 126 - 107
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/UploadFileService.java

@@ -7,6 +7,8 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
+import com.ksyun.ks3.dto.PostObjectFormFields;
+import com.yonge.toolset.thirdparty.entity.UploadSign;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -21,116 +23,133 @@ import com.yonge.toolset.thirdparty.storage.StoragePluginContext;
 import com.yonge.toolset.thirdparty.storage.provider.KS3StoragePlugin;
 import com.yonge.toolset.utils.upload.UploadUtil;
 
-/** 
+/**
  * 上传工具服务层实现类
  */
 @Service
 public class UploadFileService {
 
-	@Autowired
-	private StoragePluginContext storagePluginContext;
-
-	/** 最大上传大小,单位kb */
-	@Value("${common.upload.maxSize:153600}")
-	private int maxSize;
-
-	/** 支持的扩展名 */
-	@Value("${common.upload.supportExtensions:jpg,jpeg,gif,png,mp3,mid,midi,aac,m4a,mp4,xml,xlsx,xls,doc,docx,txt,pdf,psd,eps,rar,zip}")
-	private String supportExtensions;
-
-	/** 文件根目录 */
-	@Value("/var/tmp/")
-	private String fileRoot;
-
-	public UploadReturnBean uploadFile(InputStream in, String ext) {
-		UploadReturnBean uploadReturn = new UploadReturnBean("", false, "");
-		String fileName = UploadUtil.getFileName(ext);
-
-		String supportType = supportExtensions;
-		if (!UploadUtil.validateImgFile(ext, supportType)) {
-			uploadReturn.setMessage("上传图片格式错误,目前只支持" + supportType);
-			return uploadReturn;
-		}
-
-		String root = fileRoot;
-		if (StringUtils.isBlank(root)) {
-			uploadReturn.setMessage("上传临时目录没有配置");
-			return uploadReturn;
-		}
-
-		String staticFloder = "";
-
-		String folder = UploadUtil.getFileFloder();
-		String filePath = UploadUtil.getFilePath(root, staticFloder, folder);
-		File file = uploadFile(in, filePath, fileName);
-		if (maxSize > 0 && maxSize < file.length() / 1024) {
-			FileUtils.deleteQuietly(file);
-			uploadReturn.setMessage("超出允许的大小(" + (maxSize / 1024) + "M)限制");
-			return uploadReturn;
-		}
-
-		//String url = storagePlugin.uploadFile(staticFloder + folder, file);
-		String url = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME,staticFloder + folder, file);
-
-		FileUtils.deleteQuietly(file);
-		uploadReturn.setStatus(true);
-		uploadReturn.setUrl(url);
-		return uploadReturn;
-	}
-
-
-	@Async
-	public UploadReturnBean uploadImHistoryMsgFile(File msgFile) throws FileNotFoundException {
-		InputStream in = new FileInputStream(msgFile);
-		UploadReturnBean uploadReturn = new UploadReturnBean("", false, "");
-		String fileName = UploadUtil.getFileName(msgFile.getName());
-
-		String root = fileRoot + "im_history_msg/";
-		if (StringUtils.isBlank(root)) {
-			uploadReturn.setMessage("上传临时目录没有配置");
-			return uploadReturn;
-		}
-
-		String staticFloder = "";
-		String folder = UploadUtil.getFileFloder();
-		String filePath = UploadUtil.getFilePath(root, staticFloder, folder);
-		File file = uploadFile(in, filePath, fileName);
-		String url = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME,staticFloder + folder, file);
-
-		FileUtils.deleteQuietly(file);
-
-		uploadReturn.setStatus(true);
-		uploadReturn.setUrl(url);
-		return uploadReturn;
-	}
-
-	public void setMaxSize(int maxSize) {
-		this.maxSize = maxSize;
-	}
-
-	/**
-	 * 上传文件的工具方法
-	 * @param in
-	 * @param path
-	 * @return
-	 */
-	private File uploadFile(InputStream inputStream, String filePath, String fileName) {
-		File file = new File(filePath + "/" + fileName);
-		try {
-			if (!file.getParentFile().exists()) {
-				file.getParentFile().mkdirs();
-			}
-			FileOutputStream fos = new FileOutputStream(file);
-			IOUtils.copy(inputStream, fos);
-			if (!file.exists() || file.length() == 0) {
-				throw new BizException("图片上传出现错误,请重新上传");
-			}
-		} catch (IOException e) {
-			throw new BizException("图片上传失败", e);
-		} finally {
-			IOUtils.closeQuietly(inputStream);
-		}
-		return file;
-	}
-
+    @Autowired
+    private StoragePluginContext storagePluginContext;
+
+    /**
+     * 最大上传大小,单位kb
+     */
+    @Value("${common.upload.maxSize:153600}")
+    private int maxSize;
+
+    /**
+     * 支持的扩展名
+     */
+    @Value("${common.upload.supportExtensions:jpg,jpeg,gif,png,mp3,mid,midi,aac,m4a,mp4,xml,xlsx,xls,doc,docx,txt,pdf,psd,eps,rar,zip}")
+    private String supportExtensions;
+
+    /**
+     * 文件根目录
+     */
+    @Value("/var/tmp/")
+    private String fileRoot;
+
+    public UploadReturnBean uploadFile(InputStream in, String ext) {
+        UploadReturnBean uploadReturn = new UploadReturnBean("", false, "");
+        String fileName = UploadUtil.getFileName(ext);
+
+        String supportType = supportExtensions;
+        if (!UploadUtil.validateImgFile(ext, supportType)) {
+            uploadReturn.setMessage("上传图片格式错误,目前只支持" + supportType);
+            return uploadReturn;
+        }
+
+        String root = fileRoot;
+        if (StringUtils.isBlank(root)) {
+            uploadReturn.setMessage("上传临时目录没有配置");
+            return uploadReturn;
+        }
+
+        String staticFloder = "";
+
+        String folder = UploadUtil.getFileFloder();
+        String filePath = UploadUtil.getFilePath(root, staticFloder, folder);
+        File file = uploadFile(in, filePath, fileName);
+        if (maxSize > 0 && maxSize < file.length() / 1024) {
+            FileUtils.deleteQuietly(file);
+            uploadReturn.setMessage("超出允许的大小(" + (maxSize / 1024) + "M)限制");
+            return uploadReturn;
+        }
+
+        //String url = storagePlugin.uploadFile(staticFloder + folder, file);
+        String url = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, staticFloder + folder, file);
+
+        FileUtils.deleteQuietly(file);
+        uploadReturn.setStatus(true);
+        uploadReturn.setUrl(url);
+        return uploadReturn;
+    }
+
+
+    @Async
+    public UploadReturnBean uploadImHistoryMsgFile(File msgFile) throws FileNotFoundException {
+        InputStream in = new FileInputStream(msgFile);
+        UploadReturnBean uploadReturn = new UploadReturnBean("", false, "");
+        String fileName = UploadUtil.getFileName(msgFile.getName());
+
+        String root = fileRoot + "im_history_msg/";
+        if (StringUtils.isBlank(root)) {
+            uploadReturn.setMessage("上传临时目录没有配置");
+            return uploadReturn;
+        }
+
+        String staticFloder = "";
+        String folder = UploadUtil.getFileFloder();
+        String filePath = UploadUtil.getFilePath(root, staticFloder, folder);
+        File file = uploadFile(in, filePath, fileName);
+        String url = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, staticFloder + folder, file);
+
+        FileUtils.deleteQuietly(file);
+
+        uploadReturn.setStatus(true);
+        uploadReturn.setUrl(url);
+        return uploadReturn;
+    }
+
+    public void setMaxSize(int maxSize) {
+        this.maxSize = maxSize;
+    }
+
+    /**
+     * 上传文件的工具方法
+     *
+     * @param inputStream
+     * @param filePath
+     * @param fileName
+     * @return
+     */
+    private File uploadFile(InputStream inputStream, String filePath, String fileName) {
+        File file = new File(filePath + "/" + fileName);
+        try {
+            if (!file.getParentFile().exists()) {
+                file.getParentFile().mkdirs();
+            }
+            FileOutputStream fos = new FileOutputStream(file);
+            IOUtils.copy(inputStream, fos);
+            if (!file.exists() || file.length() == 0) {
+                throw new BizException("图片上传出现错误,请重新上传");
+            }
+        } catch (IOException e) {
+            throw new BizException("图片上传失败", e);
+        } finally {
+            IOUtils.closeQuietly(inputStream);
+        }
+        return file;
+    }
+
+    /**
+     * 获取上传文件签名
+     *
+     * @param uploadSign
+     * @return
+     */
+    public PostObjectFormFields getUploadSign(UploadSign uploadSign) {
+        return storagePluginContext.getUploadSign(KS3StoragePlugin.PLUGIN_NAME, uploadSign);
+    }
 }

+ 42 - 0
toolset/thirdparty-component/src/main/java/com/yonge/toolset/thirdparty/entity/UploadSign.java

@@ -0,0 +1,42 @@
+package com.yonge.toolset.thirdparty.entity;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Author: cy
+ * @Date: 2022/4/27
+ */
+public class UploadSign implements Serializable {
+    private String fileName;
+    
+    private Map<String, String> postData;
+    
+    private List<String> unknowValueField;
+
+    public String getFileName() {
+        return fileName;
+    }
+
+    public void setFileName(String fileName) {
+        this.fileName = fileName;
+    }
+
+    public Map<String, String> getPostData() {
+        return postData;
+    }
+
+    public void setPostData(Map<String, String> postData) {
+        this.postData = postData;
+    }
+
+    public List<String> getUnknowValueField() {
+        return unknowValueField;
+    }
+
+    public void setUnknowValueField(List<String> unknowValueField) {
+        this.unknowValueField = unknowValueField;
+    }
+}
+

+ 42 - 28
toolset/thirdparty-component/src/main/java/com/yonge/toolset/thirdparty/storage/StoragePlugin.java

@@ -1,35 +1,49 @@
 package com.yonge.toolset.thirdparty.storage;
 
+import com.ksyun.ks3.dto.PostObjectFormFields;
+import com.yonge.toolset.thirdparty.entity.UploadSign;
+
 import java.io.File;
 import java.io.IOException;
 
 public interface StoragePlugin {
-	
-	String getName();
-
-	/**
-	 * 上传文件
-	 * @param folderName 文件夹
-	 * @param file 需要上传的文件
-	 * @return 返回文件路径
-	 */
-	String uploadFile(String folderName, File file);
-
-	/**
-	 * 上传文件
-	 * @param folderName 文件夹
-	 * @param file 需要上传的文件
-	 * @param delLocalFile 删除本地文件
-	 * @return 返回文件路径
-	 */
-	String asyncUploadFile(String folderName, File file, boolean delLocalFile);
-
-	/**
-	 * 下载文件
-	 * @param folderName 文件夹
-	 * @param fileName 文件名称
-	 * @return 返回文件内容
-	 * @throws IOException
-	 */
-	byte[] getFile(String folderName, String fileName) throws IOException;
+
+    String getName();
+
+    /**
+     * 上传文件
+     *
+     * @param folderName 文件夹
+     * @param file       需要上传的文件
+     * @return 返回文件路径
+     */
+    String uploadFile(String folderName, File file);
+
+    /**
+     * 上传文件
+     *
+     * @param folderName   文件夹
+     * @param file         需要上传的文件
+     * @param delLocalFile 删除本地文件
+     * @return 返回文件路径
+     */
+    String asyncUploadFile(String folderName, File file, boolean delLocalFile);
+
+    /**
+     * 下载文件
+     *
+     * @param folderName 文件夹
+     * @param fileName   文件名称
+     * @return 返回文件内容
+     * @throws IOException
+     */
+    byte[] getFile(String folderName, String fileName) throws IOException;
+
+    /**
+     * 获取上传文件签名
+     *
+     * @param uploadSign
+     * @return
+     */
+    PostObjectFormFields getUploadSign(UploadSign uploadSign);
 }

+ 35 - 28
toolset/thirdparty-component/src/main/java/com/yonge/toolset/thirdparty/storage/StoragePluginContext.java

@@ -2,8 +2,11 @@ package com.yonge.toolset.thirdparty.storage;
 
 import java.io.File;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
+import com.ksyun.ks3.dto.PostObjectFormFields;
+import com.yonge.toolset.thirdparty.entity.UploadSign;
 import org.springframework.stereotype.Component;
 
 import com.yonge.toolset.thirdparty.exception.ThirdpartyException;
@@ -11,33 +14,37 @@ import com.yonge.toolset.thirdparty.exception.ThirdpartyException;
 @Component
 public class StoragePluginContext {
 
-	private static final Map<String, StoragePlugin> mapper = new HashMap<String, StoragePlugin>();
-	
-	public static void addStoragePlugin(StoragePlugin storagePlugin) {
-		if (mapper.containsKey(storagePlugin.getName())) {
-			throw new ThirdpartyException("存储插件:{}已存在", storagePlugin.getName());
-		}
-		mapper.put(storagePlugin.getName(), storagePlugin);
-	}
-	
-	public String uploadFile(String storagePluginName, String folderName, File file){
-		StoragePlugin StoragePlugin = getStoragePlugin(storagePluginName);
-		return StoragePlugin.uploadFile(folderName, file);
-	}
-	
-	public String asyncUploadFile(String storagePluginName, String folderName, File file, boolean delLocalFile){
-		StoragePlugin StoragePlugin = getStoragePlugin(storagePluginName);
-		return StoragePlugin.asyncUploadFile(folderName, file, delLocalFile);
-	}
-
-	private StoragePlugin getStoragePlugin(String storagePluginName) {
-		StoragePlugin storagePlugin = mapper.get(storagePluginName);
-
-		if (storagePlugin == null) {
-			throw new ThirdpartyException("存储插件:{}不存在", storagePluginName);
-		}
-
-		return storagePlugin;
-	}
+    private static final Map<String, StoragePlugin> mapper = new HashMap<String, StoragePlugin>();
 
+    public static void addStoragePlugin(StoragePlugin storagePlugin) {
+        if (mapper.containsKey(storagePlugin.getName())) {
+            throw new ThirdpartyException("存储插件:{}已存在", storagePlugin.getName());
+        }
+        mapper.put(storagePlugin.getName(), storagePlugin);
+    }
+
+    public String uploadFile(String storagePluginName, String folderName, File file) {
+        StoragePlugin StoragePlugin = getStoragePlugin(storagePluginName);
+        return StoragePlugin.uploadFile(folderName, file);
+    }
+
+    public String asyncUploadFile(String storagePluginName, String folderName, File file, boolean delLocalFile) {
+        StoragePlugin StoragePlugin = getStoragePlugin(storagePluginName);
+        return StoragePlugin.asyncUploadFile(folderName, file, delLocalFile);
+    }
+
+    public PostObjectFormFields getUploadSign(String storagePluginName, UploadSign uploadSign) {
+        StoragePlugin StoragePlugin = getStoragePlugin(storagePluginName);
+        return StoragePlugin.getUploadSign(uploadSign);
+    }
+
+    private StoragePlugin getStoragePlugin(String storagePluginName) {
+        StoragePlugin storagePlugin = mapper.get(storagePluginName);
+
+        if (storagePlugin == null) {
+            throw new ThirdpartyException("存储插件:{}不存在", storagePluginName);
+        }
+
+        return storagePlugin;
+    }
 }

+ 187 - 138
toolset/thirdparty-component/src/main/java/com/yonge/toolset/thirdparty/storage/provider/AliyunOssStoragePlugin.java

@@ -2,8 +2,17 @@ package com.yonge.toolset.thirdparty.storage.provider;
 
 import java.io.File;
 import java.io.IOException;
-
+import java.util.List;
+import java.util.Map;
+
+import com.alibaba.fastjson.JSON;
+import com.ksyun.ks3.dto.PostObjectFormFields;
+import com.ksyun.ks3.service.Ks3;
+import com.ksyun.ks3.service.Ks3Client;
+import com.ksyun.ks3.service.Ks3ClientConfig;
+import com.yonge.toolset.thirdparty.entity.UploadSign;
 import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.util.IOUtils;
 import org.springframework.beans.factory.DisposableBean;
 import org.springframework.beans.factory.InitializingBean;
@@ -20,141 +29,181 @@ import com.yonge.toolset.thirdparty.storage.StoragePluginContext;
 @Component
 public class AliyunOssStoragePlugin implements StoragePlugin, InitializingBean, DisposableBean {
 
-	public final static String PLUGIN_NAME = "Aliyun";
-
-	@Value("${storage.oss.endpoint:oss-cn-beijing.aliyuncs.com}")
-	private String endpoint;
-
-	@Value("${storage.oss.accessKeyId:LTAI4Fdhxwfo7FsBDZKK8Wfv}")
-	private String accessKeyId;
-
-	@Value("${storage.oss.accessKeySecret:ERRma4P9VWbD98n93gspnZXmoq7rn5}")
-	private String accessKeySecret;
-
-	@Value("${storage.oss.bucketName:daya-online}")
-	private String bucketName;
-
-	private OSSClient ossClient;
-
-	public String getName() {
-		return PLUGIN_NAME;
-	}
-
-	@Override
-	public void afterPropertiesSet() throws Exception {
-		// 创建ClientConfiguration。ClientConfiguration是OSSClient的配置类,可配置代理、连接超时、最大连接数等参数。
-		ClientConfiguration conf = new ClientConfiguration();
-
-		// 设置OSSClient允许打开的最大HTTP连接数,默认为1024个。
-		conf.setMaxConnections(200);
-		// 设置Socket层传输数据的超时时间,默认为50000毫秒。
-		conf.setSocketTimeout(10000);
-		// 设置建立连接的超时时间,默认为50000毫秒。
-		conf.setConnectionTimeout(10000);
-		// 设置从连接池中获取连接的超时时间(单位:毫秒),默认不超时。
-		conf.setConnectionRequestTimeout(1000);
-		// 设置连接空闲超时时间。超时则关闭连接,默认为60000毫秒。
-		conf.setIdleConnectionTime(10000);
-		// 设置失败请求重试次数,默认为3次。
-		conf.setMaxErrorRetry(5);
-		// 设置是否支持将自定义域名作为Endpoint,默认支持。
-		conf.setSupportCname(true);
-
-		ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret, conf);
-		
-		StoragePluginContext.addStoragePlugin(this);
-	}
-
-	@Override
-	public String uploadFile(String folderName, File file) {
-		if (!file.exists()) {
-			throw new ThirdpartyException("需要上传的文件[{}]不存在", file.getAbsolutePath());
-		}
-
-		if (folderName.endsWith("/")) {
-			folderName = folderName.substring(0, folderName.length() - 1);
-		}
-
-		ossClient.putObject(bucketName, folderName + "/" + file.getName(), file);
-
-		return "https://" + bucketName + "." + endpoint + "/" + folderName + "/" + file.getName();
-	}
-
-	@Override
-	public String asyncUploadFile(String folderName, File file, boolean delLocalFile) {
-		if (!file.exists()) {
-			throw new ThirdpartyException("需要上传的文件[{}]不存在", file.getAbsolutePath());
-		}
-
-		if (folderName.endsWith("/")) {
-			folderName = folderName.substring(0, folderName.length() - 1);
-		}
-		
-		final String dir = folderName;
-		
-		Thread thread = new Thread(new Runnable() {
-			
-			@Override
-			public void run() {
-				ossClient.putObject(bucketName, dir + "/" + file.getName(), file);
-				if(delLocalFile){
-					FileUtils.deleteQuietly(file);
-				}
-			}
-		});
-		thread.start();
-
-		return "https://" + bucketName + "." + endpoint + "/" + folderName + "/" + file.getName();
-	}
-
-	@Override
-	public byte[] getFile(String folderName, String fileName) throws IOException {
-		OSSObject ossObject = ossClient.getObject(bucketName, folderName + "/" + fileName);
-		try {
-			return IOUtils.toByteArray(ossObject.getObjectContent());
-		} finally {
-			if (ossObject != null) {
-				ossObject.close();
-			}
-		}
-	}
-
-	@Override
-	public void destroy() throws Exception {
-		if (ossClient != null) {
-			ossClient.shutdown();
-		}
-	}
-
-	public void setEndpoint(String endpoint) {
-		this.endpoint = endpoint;
-	}
-
-	public void setAccessKeyId(String accessKeyId) {
-		this.accessKeyId = accessKeyId;
-	}
-
-	public void setAccessKeySecret(String accessKeySecret) {
-		this.accessKeySecret = accessKeySecret;
-	}
-
-	public void setBucketName(String bucketName) {
-		this.bucketName = bucketName;
-	}
-
-	public static void main(String[] args) throws Exception {
-		AliyunOssStoragePlugin aliyunOssStorageService = new AliyunOssStoragePlugin();
-		aliyunOssStorageService.setAccessKeyId("LTAIwZW9XqrfsZ4r");
-		aliyunOssStorageService.setAccessKeySecret("5uDsNZmHMxcnxav8w9byII4zcPpu5G");
-		aliyunOssStorageService.setBucketName("yooma-test");
-		aliyunOssStorageService.setEndpoint("oss-cn-beijing.aliyuncs.com");
-		aliyunOssStorageService.afterPropertiesSet();
-
-		File file = new File("e:/var/2.jpg");
-		System.out.println(aliyunOssStorageService.uploadFile("aaa", file));
-
-		System.err.println("***********" + aliyunOssStorageService.getFile("aaa", file.getName()).length);
-
-		aliyunOssStorageService.destroy();
-	}
+    public final static String PLUGIN_NAME = "Aliyun";
+
+    @Value("${storage.oss.endpoint:oss-cn-beijing.aliyuncs.com}")
+    private String endpoint;
+
+    @Value("${storage.oss.accessKeyId:LTAI4Fdhxwfo7FsBDZKK8Wfv}")
+    private String accessKeyId;
+
+    @Value("${storage.oss.accessKeySecret:ERRma4P9VWbD98n93gspnZXmoq7rn5}")
+    private String accessKeySecret;
+
+    @Value("${storage.oss.bucketName:daya-online}")
+    private String bucketName;
+
+    private OSSClient ossClient;
+
+    public String getName() {
+        return PLUGIN_NAME;
+    }
+
+    @Override
+    public void afterPropertiesSet() throws Exception {
+        // 创建ClientConfiguration。ClientConfiguration是OSSClient的配置类,可配置代理、连接超时、最大连接数等参数。
+        ClientConfiguration conf = new ClientConfiguration();
+
+        // 设置OSSClient允许打开的最大HTTP连接数,默认为1024个。
+        conf.setMaxConnections(200);
+        // 设置Socket层传输数据的超时时间,默认为50000毫秒。
+        conf.setSocketTimeout(10000);
+        // 设置建立连接的超时时间,默认为50000毫秒。
+        conf.setConnectionTimeout(10000);
+        // 设置从连接池中获取连接的超时时间(单位:毫秒),默认不超时。
+        conf.setConnectionRequestTimeout(1000);
+        // 设置连接空闲超时时间。超时则关闭连接,默认为60000毫秒。
+        conf.setIdleConnectionTime(10000);
+        // 设置失败请求重试次数,默认为3次。
+        conf.setMaxErrorRetry(5);
+        // 设置是否支持将自定义域名作为Endpoint,默认支持。
+        conf.setSupportCname(true);
+
+        ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret, conf);
+
+        StoragePluginContext.addStoragePlugin(this);
+    }
+
+    @Override
+    public String uploadFile(String folderName, File file) {
+        if (!file.exists()) {
+            throw new ThirdpartyException("需要上传的文件[{}]不存在", file.getAbsolutePath());
+        }
+
+        if (folderName.endsWith("/")) {
+            folderName = folderName.substring(0, folderName.length() - 1);
+        }
+
+        ossClient.putObject(bucketName, folderName + "/" + file.getName(), file);
+
+        return "https://" + bucketName + "." + endpoint + "/" + folderName + "/" + file.getName();
+    }
+
+    @Override
+    public String asyncUploadFile(String folderName, File file, boolean delLocalFile) {
+        if (!file.exists()) {
+            throw new ThirdpartyException("需要上传的文件[{}]不存在", file.getAbsolutePath());
+        }
+
+        if (folderName.endsWith("/")) {
+            folderName = folderName.substring(0, folderName.length() - 1);
+        }
+
+        final String dir = folderName;
+
+        Thread thread = new Thread(new Runnable() {
+
+            @Override
+            public void run() {
+                ossClient.putObject(bucketName, dir + "/" + file.getName(), file);
+                if (delLocalFile) {
+                    FileUtils.deleteQuietly(file);
+                }
+            }
+        });
+        thread.start();
+
+        return "https://" + bucketName + "." + endpoint + "/" + folderName + "/" + file.getName();
+    }
+
+    @Override
+    public byte[] getFile(String folderName, String fileName) throws IOException {
+        OSSObject ossObject = ossClient.getObject(bucketName, folderName + "/" + fileName);
+        try {
+            return IOUtils.toByteArray(ossObject.getObjectContent());
+        } finally {
+            if (ossObject != null) {
+                ossObject.close();
+            }
+        }
+    }
+
+    @Override
+    public PostObjectFormFields getUploadSign(UploadSign uploadSign) {
+        //要上传的文件名称,不包含路径信息
+        String fileName = uploadSign.getFileName();
+        //可以确定值得表单项
+        Map<String, String> postData = uploadSign.getPostData();
+        //无法确定值得表单项
+        List<String> unknowValueField = uploadSign.getUnknowValueField();
+
+        Ks3ClientConfig config = new Ks3ClientConfig();
+        // 设置域名
+        config.setEndpoint(endpoint);
+        // 创建Ks3Client实例
+        Ks3 client = new Ks3Client(accessKeyId, accessKeySecret, config);
+
+        /**
+         * 需要用户在postData和unknowValueField中提供所有的除KSSAccessKeyId, signature, file, policy外的所有表单项。否则用生成的签名上传会返回403</br>
+         * 对于用户可以确定表单值的放在 postData中,对于用户无法确定表单值的放在unknownValueField中(比如有的上传控件会添加一些表单项,但表单项的值可能是随机的)</br>
+         */
+        //Map<String, String> postData = new HashMap<String, String>();
+        // 如果使用js sdk上传的时候设置了ACL,请提供以下一行,且值要与SDK中一致,否则删除下面一行代码
+        //postData.put("acl","public-read");
+        // 提供js sdk中的key值
+        //postData.put("key","20150115/中文/${filename}");
+        // 设置无法确定的表单值
+        //List<String> unknowValueField = new ArrayList<String>();
+
+        // js sdk上传的时候会自动加上一个name的表单项,所以下面需要加上这样的代码。
+        unknowValueField.add("name");
+
+        // 如果计算签名时提供的key里不包含${filename}占位符,第二个参数传一个空字符串。
+        String postDataKey = postData.get("key");
+        if (StringUtils.isNotBlank(postDataKey)) {
+            if (postDataKey.indexOf("${filename}") == -1) {
+                return client.postObject(bucketName, "", postData, unknowValueField);
+            }
+        }
+        return client.postObject(bucketName, fileName, postData, unknowValueField);
+    }
+
+    @Override
+    public void destroy() throws Exception {
+        if (ossClient != null) {
+            ossClient.shutdown();
+        }
+    }
+
+    public void setEndpoint(String endpoint) {
+        this.endpoint = endpoint;
+    }
+
+    public void setAccessKeyId(String accessKeyId) {
+        this.accessKeyId = accessKeyId;
+    }
+
+    public void setAccessKeySecret(String accessKeySecret) {
+        this.accessKeySecret = accessKeySecret;
+    }
+
+    public void setBucketName(String bucketName) {
+        this.bucketName = bucketName;
+    }
+
+    public static void main(String[] args) throws Exception {
+        AliyunOssStoragePlugin aliyunOssStorageService = new AliyunOssStoragePlugin();
+        aliyunOssStorageService.setAccessKeyId("LTAIwZW9XqrfsZ4r");
+        aliyunOssStorageService.setAccessKeySecret("5uDsNZmHMxcnxav8w9byII4zcPpu5G");
+        aliyunOssStorageService.setBucketName("yooma-test");
+        aliyunOssStorageService.setEndpoint("oss-cn-beijing.aliyuncs.com");
+        aliyunOssStorageService.afterPropertiesSet();
+
+        File file = new File("e:/var/2.jpg");
+        System.out.println(aliyunOssStorageService.uploadFile("aaa", file));
+
+        System.err.println("***********" + aliyunOssStorageService.getFile("aaa", file.getName()).length);
+
+        aliyunOssStorageService.destroy();
+    }
 }

+ 187 - 182
toolset/thirdparty-component/src/main/java/com/yonge/toolset/thirdparty/storage/provider/KS3StoragePlugin.java

@@ -2,13 +2,12 @@ package com.yonge.toolset.thirdparty.storage.provider;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import com.alibaba.fastjson.JSON;
 import com.ksyun.ks3.dto.PostObjectFormFields;
+import com.yonge.toolset.thirdparty.entity.UploadSign;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.util.IOUtils;
@@ -34,184 +33,190 @@ import com.yonge.toolset.thirdparty.storage.StoragePluginContext;
 @Component
 public class KS3StoragePlugin implements StoragePlugin, InitializingBean, DisposableBean {
 
-	public final static String PLUGIN_NAME = "Ksyun";
-
-	@Value("${storage.oss.endpoint:ks3-cn-beijing.ksyun.com}")
-	private String endpoint;
-
-	@Value("${storage.oss.accessKeyId:AKLTtTeIbadpRG-pil4S0Q4m-Q}")
-	private String accessKeyId;
-
-	@Value("${storage.oss.accessKeySecret:OB1HmNOfDNW95wHoxMkP6IPFZXormk2ngA800TkvKAw7ozhiJGRqrMnnV8ZrAU3WRQ==}")
-	private String accessKeySecret;
-
-	@Value("${storage.oss.bucketName:daya}")
-	private String bucketName;
-
-	private Ks3 client;
-
-	public String getName() {
-		return PLUGIN_NAME;
-	}
-
-	@Override
-	public void afterPropertiesSet() throws Exception {
-		Ks3ClientConfig config = new Ks3ClientConfig();
-		config.setEndpoint(endpoint);// 如果使用自定义域名,设置endpoint为自定义域名,同时设置domainMode为true
-		/**
-		 * true:表示以自定义域名访问 
-		 * false:表示以KS3的外网域名或内网域名访问
-		 * 默认为false
-		 */
-		config.setDomainMode(false);
-		config.setProtocol(PROTOCOL.http);
-
-		/**
-		 * true表示以   endpoint/{bucket}/{key}的方式访问
-		 * false表示以  {bucket}.endpoint/{key}的方式访问
-		 * 如果domainMode设置为true,pathStyleAccess可忽略设置
-		 */
-		config.setPathStyleAccess(false);
-		HttpClientConfig hconfig = new HttpClientConfig();
-		// 在HttpClientConfig中可以设置httpclient的相关属性,比如代理,超时,重试等。
-		config.setHttpClientConfig(hconfig);
-		client = new Ks3Client(accessKeyId, accessKeySecret, config);
-
-		StoragePluginContext.addStoragePlugin(this);
-	}
-
-	@Override
-	public String uploadFile(String folderName, File file) {
-		if (!file.exists()) {
-			throw new ThirdpartyException("需要上传的文件[{}]不存在", file.getAbsolutePath());
-		}
-
-		if (folderName.endsWith("/")) {
-			folderName = folderName.substring(0, folderName.length() - 1);
-		}
-
-		PutObjectRequest request = new PutObjectRequest(bucketName, folderName + "/" + file.getName(), file);
-
-		// 上传一个公开文件
-		request.setCannedAcl(CannedAccessControlList.PublicRead);
-
-		client.putObject(request);
-
-		return "https://" + bucketName + "." + endpoint + "/" + folderName + "/" + file.getName();
-	}
-
-	@Override
-	public String asyncUploadFile(String folderName, File file, boolean delLocalFile) {
-		if (!file.exists()) {
-			throw new ThirdpartyException("需要上传的文件[{}]不存在", file.getAbsolutePath());
-		}
-
-		if (folderName.endsWith("/")) {
-			folderName = folderName.substring(0, folderName.length() - 1);
-		}
-
-		PutObjectRequest request = new PutObjectRequest(bucketName, folderName + "/" + file.getName(), file);
-
-		// 上传一个公开文件
-		request.setCannedAcl(CannedAccessControlList.PublicRead);
-		
-		Thread thread = new Thread(new Runnable() {
-			
-			@Override
-			public void run() {
-				client.putObject(request);
-				if(delLocalFile){
-					FileUtils.deleteQuietly(file);
-				}
-			}
-		});
-		thread.start();
-
-		return "https://" + bucketName + "." + endpoint + "/" + folderName + "/" + file.getName();
-	}
-
-	@Override
-	public byte[] getFile(String folderName, String fileName) throws IOException {
-		GetObjectRequest request = new GetObjectRequest(bucketName, folderName + "/" + fileName);
-		GetObjectResult result = client.getObject(request);
-
-		Ks3Object object = result.getObject();
-		try {
-			return IOUtils.toByteArray(object.getObjectContent());
-		} finally {
-			if (object != null) {
-				object.close();
-			}
-		}
-	}
-
-	public String postObjectSimple(Map<String, String> postData,List<String> unknowValueField) {
-		// yourEndpoint填写Bucket所在地域对应的Endpoint。以中国(北京)为例,Endpoint填写为ks3-cn-beijing.ksyuncs.com。如果使用自定义域名,设置endpoint为自定义域名,同时设置domainMode为true
-		//String endpoint = "yourEndpoint";
-		// 金山云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用子账号账号进行 API 访问或日常运维,请登录 https://uc.console.ksyun.com/pro/iam/#/user/list 创建子账号。
-		//String accessKeyId = "yourAccessKeyId";
-		//String accessKeySecret = "yourAccessKeySecret";
-		// 创建Ks3ClientConfig 实例。
-		Ks3ClientConfig config = new Ks3ClientConfig();
-		// 设置域名
-		config.setEndpoint(endpoint);
-		// 创建Ks3Client实例
-		Ks3 client = new Ks3Client(accessKeyId, accessKeySecret, config);
-		/**
-		 * 需要用户在postData和unknowValueField中提供所有的除KSSAccessKeyId, signature, file, policy外的所有表单项。否则用生成的签名上传会返回403</br>
-		 * 对于用户可以确定表单值的放在 postData中,对于用户无法确定表单值的放在unknownValueField中(比如有的上传控件会添加一些表单项,但表单项的值可能是随机的)</br>
-		 */
-		//Map<String, String> postData = new HashMap<String, String>();
-		// 如果使用js sdk上传的时候设置了ACL,请提供以下一行,且值要与SDK中一致,否则删除下面一行代码
-		//postData.put("acl","public-read");
-		// 提供js sdk中的key值
-		//postData.put("key","20150115/中文/${filename}");
-		// 设置无法确定的表单值
-		//List<String> unknowValueField = new ArrayList<String>();
-		// js sdk上传的时候会自动加上一个name的表单项,所以下面需要加上这样的代码。
-		unknowValueField.add("name");
-		// 如果计算签名时提供的key里不包含${filename}占位符,第二个参数传一个空字符串。
-		String postDataKey = postData.get("key");
-		if (StringUtils.isNotBlank(postDataKey)){
-
-		}
-		PostObjectFormFields fields = client.postObject(bucketName, "<要上传的文件名称,不包含路径信息>", postData, unknowValueField);
-		return JSON.toJSONString(fields);
-	}
-
-	@Override
-	public void destroy() throws Exception {
-	}
-
-	public void setEndpoint(String endpoint) {
-		this.endpoint = endpoint;
-	}
-
-	public void setAccessKeyId(String accessKeyId) {
-		this.accessKeyId = accessKeyId;
-	}
-
-	public void setAccessKeySecret(String accessKeySecret) {
-		this.accessKeySecret = accessKeySecret;
-	}
-
-	public void setBucketName(String bucketName) {
-		this.bucketName = bucketName;
-	}
-
-	public static void main(String[] args) throws Exception {
-		KS3StoragePlugin aliyunOssStorageService = new KS3StoragePlugin();
-		aliyunOssStorageService.setAccessKeyId("LTAIwZW9XqrfsZ4r");
-		aliyunOssStorageService.setAccessKeySecret("5uDsNZmHMxcnxav8w9byII4zcPpu5G");
-		aliyunOssStorageService.setBucketName("yooma-test");
-		aliyunOssStorageService.setEndpoint("oss-cn-beijing.aliyuncs.com");
-		aliyunOssStorageService.afterPropertiesSet();
-
-		File file = new File("e:/var/2.jpg");
-		System.out.println(aliyunOssStorageService.uploadFile("aaa", file));
-
-		System.err.println("***********" + aliyunOssStorageService.getFile("aaa", file.getName()).length);
-
-		aliyunOssStorageService.destroy();
-	}
+    public final static String PLUGIN_NAME = "Ksyun";
+
+    @Value("${storage.oss.endpoint:ks3-cn-beijing.ksyun.com}")
+    private String endpoint;
+
+    @Value("${storage.oss.accessKeyId:AKLTtTeIbadpRG-pil4S0Q4m-Q}")
+    private String accessKeyId;
+
+    @Value("${storage.oss.accessKeySecret:OB1HmNOfDNW95wHoxMkP6IPFZXormk2ngA800TkvKAw7ozhiJGRqrMnnV8ZrAU3WRQ==}")
+    private String accessKeySecret;
+
+    @Value("${storage.oss.bucketName:daya}")
+    private String bucketName;
+
+    private Ks3 client;
+
+    public String getName() {
+        return PLUGIN_NAME;
+    }
+
+    @Override
+    public void afterPropertiesSet() throws Exception {
+        Ks3ClientConfig config = new Ks3ClientConfig();
+        config.setEndpoint(endpoint);// 如果使用自定义域名,设置endpoint为自定义域名,同时设置domainMode为true
+        /**
+         * true:表示以自定义域名访问
+         * false:表示以KS3的外网域名或内网域名访问
+         * 默认为false
+         */
+        config.setDomainMode(false);
+        config.setProtocol(PROTOCOL.http);
+
+        /**
+         * true表示以   endpoint/{bucket}/{key}的方式访问
+         * false表示以  {bucket}.endpoint/{key}的方式访问
+         * 如果domainMode设置为true,pathStyleAccess可忽略设置
+         */
+        config.setPathStyleAccess(false);
+        HttpClientConfig hconfig = new HttpClientConfig();
+        // 在HttpClientConfig中可以设置httpclient的相关属性,比如代理,超时,重试等。
+        config.setHttpClientConfig(hconfig);
+        client = new Ks3Client(accessKeyId, accessKeySecret, config);
+
+        StoragePluginContext.addStoragePlugin(this);
+    }
+
+    @Override
+    public String uploadFile(String folderName, File file) {
+        if (!file.exists()) {
+            throw new ThirdpartyException("需要上传的文件[{}]不存在", file.getAbsolutePath());
+        }
+
+        if (folderName.endsWith("/")) {
+            folderName = folderName.substring(0, folderName.length() - 1);
+        }
+
+        PutObjectRequest request = new PutObjectRequest(bucketName, folderName + "/" + file.getName(), file);
+
+        // 上传一个公开文件
+        request.setCannedAcl(CannedAccessControlList.PublicRead);
+
+        client.putObject(request);
+
+        return "https://" + bucketName + "." + endpoint + "/" + folderName + "/" + file.getName();
+    }
+
+    @Override
+    public String asyncUploadFile(String folderName, File file, boolean delLocalFile) {
+        if (!file.exists()) {
+            throw new ThirdpartyException("需要上传的文件[{}]不存在", file.getAbsolutePath());
+        }
+
+        if (folderName.endsWith("/")) {
+            folderName = folderName.substring(0, folderName.length() - 1);
+        }
+
+        PutObjectRequest request = new PutObjectRequest(bucketName, folderName + "/" + file.getName(), file);
+
+        // 上传一个公开文件
+        request.setCannedAcl(CannedAccessControlList.PublicRead);
+
+        Thread thread = new Thread(new Runnable() {
+
+            @Override
+            public void run() {
+                client.putObject(request);
+                if (delLocalFile) {
+                    FileUtils.deleteQuietly(file);
+                }
+            }
+        });
+        thread.start();
+
+        return "https://" + bucketName + "." + endpoint + "/" + folderName + "/" + file.getName();
+    }
+
+    @Override
+    public byte[] getFile(String folderName, String fileName) throws IOException {
+        GetObjectRequest request = new GetObjectRequest(bucketName, folderName + "/" + fileName);
+        GetObjectResult result = client.getObject(request);
+
+        Ks3Object object = result.getObject();
+        try {
+            return IOUtils.toByteArray(object.getObjectContent());
+        } finally {
+            if (object != null) {
+                object.close();
+            }
+        }
+    }
+
+    @Override
+    public PostObjectFormFields getUploadSign(UploadSign uploadSign) {
+        //要上传的文件名称,不包含路径信息
+        String fileName = uploadSign.getFileName();
+        //可以确定值得表单项
+        Map<String, String> postData = uploadSign.getPostData();
+        //无法确定值得表单项
+        List<String> unknowValueField = uploadSign.getUnknowValueField();
+
+        Ks3ClientConfig config = new Ks3ClientConfig();
+        // 设置域名
+        config.setEndpoint(endpoint);
+        // 创建Ks3Client实例
+        Ks3 client = new Ks3Client(accessKeyId, accessKeySecret, config);
+
+        /**
+         * 需要用户在postData和unknowValueField中提供所有的除KSSAccessKeyId, signature, file, policy外的所有表单项。否则用生成的签名上传会返回403</br>
+         * 对于用户可以确定表单值的放在 postData中,对于用户无法确定表单值的放在unknownValueField中(比如有的上传控件会添加一些表单项,但表单项的值可能是随机的)</br>
+         */
+        //Map<String, String> postData = new HashMap<String, String>();
+        // 如果使用js sdk上传的时候设置了ACL,请提供以下一行,且值要与SDK中一致,否则删除下面一行代码
+        //postData.put("acl","public-read");
+        // 提供js sdk中的key值
+        //postData.put("key","20150115/中文/${filename}");
+        // 设置无法确定的表单值
+        //List<String> unknowValueField = new ArrayList<String>();
+
+        // js sdk上传的时候会自动加上一个name的表单项,所以下面需要加上这样的代码。
+        unknowValueField.add("name");
+
+        // 如果计算签名时提供的key里不包含${filename}占位符,第二个参数传一个空字符串。
+        String postDataKey = postData.get("key");
+        if (StringUtils.isNotBlank(postDataKey)) {
+            if (postDataKey.indexOf("${filename}") == -1) {
+                return client.postObject(bucketName, "", postData, unknowValueField);
+            }
+        }
+        return client.postObject(bucketName, fileName, postData, unknowValueField);
+    }
+
+    @Override
+    public void destroy() throws Exception {
+    }
+
+    public void setEndpoint(String endpoint) {
+        this.endpoint = endpoint;
+    }
+
+    public void setAccessKeyId(String accessKeyId) {
+        this.accessKeyId = accessKeyId;
+    }
+
+    public void setAccessKeySecret(String accessKeySecret) {
+        this.accessKeySecret = accessKeySecret;
+    }
+
+    public void setBucketName(String bucketName) {
+        this.bucketName = bucketName;
+    }
+
+    public static void main(String[] args) throws Exception {
+        KS3StoragePlugin aliyunOssStorageService = new KS3StoragePlugin();
+        aliyunOssStorageService.setAccessKeyId("LTAIwZW9XqrfsZ4r");
+        aliyunOssStorageService.setAccessKeySecret("5uDsNZmHMxcnxav8w9byII4zcPpu5G");
+        aliyunOssStorageService.setBucketName("yooma-test");
+        aliyunOssStorageService.setEndpoint("oss-cn-beijing.aliyuncs.com");
+        aliyunOssStorageService.afterPropertiesSet();
+
+        File file = new File("e:/var/2.jpg");
+        System.out.println(aliyunOssStorageService.uploadFile("aaa", file));
+
+        System.err.println("***********" + aliyunOssStorageService.getFile("aaa", file.getName()).length);
+
+        aliyunOssStorageService.destroy();
+    }
 }