|
|
@@ -436,15 +436,19 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- private String uploadPic(String url, String prefix) throws IOException {
|
|
|
+ private static String uploadPic(String url, String prefix) throws IOException {
|
|
|
byte[] body = HttpUtil.downloadBytes(url);
|
|
|
- Path tempFile = Files.createTempFile(Path.of("/mnt/pirture"),prefix, ".png");
|
|
|
+ Path tempFile = Files.createTempFile(prefix, ".png");
|
|
|
File file = tempFile.toFile();
|
|
|
try (FileImageOutputStream imageOutput = new FileImageOutputStream(file)) {
|
|
|
imageOutput.write(body, 0, body.length);
|
|
|
}
|
|
|
- return midjourneyCdnHost + "/picture/" + file.getName();
|
|
|
+ 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");
|
|
|
}
|
|
|
|
|
|
private static List<String> uploadBase64Pic(List<String> base64Array) throws IOException {
|