|
|
@@ -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 {
|