|
@@ -1,10 +1,12 @@
|
|
|
package com.bosshand.virgo.file.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.bosshand.virgo.core.response.Response;
|
|
|
import com.bosshand.virgo.exception.BadRequestException;
|
|
|
import com.bosshand.virgo.exception.Constant;
|
|
|
import com.bosshand.virgo.file.model.FileNode;
|
|
|
import com.bosshand.virgo.file.service.FileManagerService;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -14,10 +16,12 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.OutputStream;
|
|
|
import java.net.URLEncoder;
|
|
|
+import java.util.Base64;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -100,6 +104,25 @@ public class FileNodeController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("上传base64")
|
|
|
+ @RequestMapping(value = "/filenode/base64", method = RequestMethod.POST)
|
|
|
+ public Response uploadFileBase64(@RequestBody JSONObject jsonObject) {
|
|
|
+ InputStream inputStream = null;
|
|
|
+ try {
|
|
|
+ Base64.Decoder decoder = Base64.getDecoder();
|
|
|
+ byte[] imageByte = decoder.decode(jsonObject.getString("base64").split(",")[1]);
|
|
|
+ inputStream = new ByteArrayInputStream(imageByte);
|
|
|
+ return Response.ok(fileManagerService.create(inputStream, "签名.png", -1));
|
|
|
+ } finally {
|
|
|
+ if (inputStream != null) {
|
|
|
+ try {
|
|
|
+ inputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@RequestMapping(value = "/filenode/{id}", method = RequestMethod.GET)
|
|
|
public void getFile(@PathVariable int id, final HttpServletResponse response) throws Exception {
|
|
|
|