|
@@ -1,32 +0,0 @@
|
|
|
-package com.fdkankan.web.controller;
|
|
|
-
|
|
|
-import com.fdkankan.base.constant.LoginConstant;
|
|
|
-import com.fdkankan.common.exception.BaseRuntimeException;
|
|
|
-import com.fdkankan.common.model.ViewResult;
|
|
|
-import com.fdkankan.common.util.FileUtils;
|
|
|
-import org.springframework.util.ObjectUtils;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
-import java.io.IOException;
|
|
|
-
|
|
|
-@RestController
|
|
|
-@RequestMapping("/openapi/file")
|
|
|
-public class OpenApiController {
|
|
|
-
|
|
|
- private final String base64Prefix= "data:image/jpg;base64,";
|
|
|
-
|
|
|
- @PostMapping(value = "/getBase64")
|
|
|
- public ViewResult getBase64(String fileUrl) {
|
|
|
- if (ObjectUtils.isEmpty(fileUrl)) {
|
|
|
- throw new BaseRuntimeException(LoginConstant.FAILURE_CODE_3001, LoginConstant.FAILURE_MSG_3001);
|
|
|
- }
|
|
|
- try {
|
|
|
- return ViewResult.success(base64Prefix.concat(FileUtils.getBase64ContentFromUrl(fileUrl)));
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- return ViewResult.error(e.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
-}
|