Browse Source

fix 图片保存本地

zwhui 2 years ago
parent
commit
c37e002c09

+ 4 - 7
netflix-service/src/main/java/com/cyksj/service/midjourney/impl/MidjourneyServiceImpl.java

@@ -65,6 +65,8 @@ public class MidjourneyServiceImpl implements MidjourneyService {
 
     @Value("${midjourney.url}")
     private String midjourneyHost;
+    @Value("${midjourney.cdn}")
+    private String midjourneyCdnHost;
 
     private final EnvCommonService envCommonService;
 
@@ -435,19 +437,14 @@ public class MidjourneyServiceImpl implements MidjourneyService {
     }
 
 
-    private static String uploadPic(String url, String prefix) throws IOException {
+    private String uploadPic(String url, String prefix) throws IOException {
         byte[] body = HttpUtil.downloadBytes(url);
         Path tempFile = Files.createTempFile(prefix, ".png");
         File file = tempFile.toFile();
         try (FileImageOutputStream imageOutput = new FileImageOutputStream(file)) {
             imageOutput.write(body, 0, body.length);
         }
-        Map<String, Object> paramMap = new HashMap<>();
-        paramMap.put("file", file);
-        String json = HttpUtil.post("https://files.liuliangbang.vip/pic/ups", paramMap);
-        log.info("上传图片结果:url:{},json:{}",url, json);
-        FileUtil.del(file);
-        return new JSONObject(json).getJSONObject("value").getJSONArray("saved").getJSONObject(0).getJSONObject("info").getStr("cdnUrl");
+        return midjourneyCdnHost + "/picture/" + file.getName();
     }
 
     private static List<String> uploadBase64Pic(List<String> base64Array) throws IOException {

File diff suppressed because it is too large
+ 0 - 0
netflix-web/src/main/resources/application-dev.yml


File diff suppressed because it is too large
+ 0 - 0
netflix-web/src/main/resources/application-prd.yml


+ 2 - 1
netflix-web/src/main/resources/application-pre.yml

@@ -197,4 +197,5 @@ smsVerify:
 
 midjourney:
   url: https://nf.video
-  drawUrl: https://nf.video/drawTest/web/
+  drawUrl: https://nf.video/drawTest/web/
+  cdn: https://nf.video

Some files were not shown because too many files changed in this diff