|
|
@@ -287,8 +287,13 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
private static List<String> uploadBase64Pic(List<String> base64Array) throws IOException {
|
|
|
List<String> list = new ArrayList<>();
|
|
|
for (String base64 : base64Array) {
|
|
|
+ String fileExt = "jpeg";
|
|
|
+ if (base64.contains(";")){
|
|
|
+ fileExt = base64.split(";")[0].split("/")[1];
|
|
|
+ base64 = base64.split(",")[1];
|
|
|
+ }
|
|
|
byte[] body = Base64.getDecoder().decode(base64);
|
|
|
- Path tempFile = Files.createTempFile(UUID.randomUUID().toString(), ".jpeg");
|
|
|
+ Path tempFile = Files.createTempFile(UUID.randomUUID().toString(), "." + fileExt);
|
|
|
try (FileImageOutputStream imageOutput = new FileImageOutputStream(tempFile.toFile())) {
|
|
|
imageOutput.write(body, 0, body.length);
|
|
|
}
|