design Single 允许画笔修改sketch后进行design
This commit is contained in:
@@ -8,6 +8,8 @@ import io.minio.http.Method;
|
||||
import io.minio.messages.DeleteError;
|
||||
import io.minio.messages.DeleteObject;
|
||||
import io.minio.messages.Item;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -26,6 +28,7 @@ import java.util.stream.Collectors;
|
||||
* @description: minio工具类
|
||||
* @version:3.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MinioUtil {
|
||||
@Autowired
|
||||
@@ -437,11 +440,33 @@ public class MinioUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public String base64Upload(String base64, String bucketName){
|
||||
public String base64UploadToPath(String base64, String bucketName, String path){
|
||||
String[] parts = base64.split(",");
|
||||
String imageType = parts[0].split("/")[1].split(";")[0];
|
||||
String base64Data = parts[1];
|
||||
return uploadImageFromBase64(bucketName, base64Data, imageType);
|
||||
|
||||
byte[] imageBytes = Base64.getDecoder().decode(base64Data);
|
||||
String fileName;
|
||||
if (!StringUtil.isNullOrEmpty(path)){
|
||||
fileName = path + "." + imageType; // or any other image format
|
||||
}else {
|
||||
fileName = UUID.randomUUID() + "." + imageType;
|
||||
}
|
||||
|
||||
try (InputStream in = new ByteArrayInputStream(imageBytes)) {
|
||||
minioClient.putObject(PutObjectArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.object(fileName)
|
||||
.stream(in, in.available(), -1)
|
||||
.contentType("image/" + imageType) // Set the content type according to your image format
|
||||
.build()
|
||||
);
|
||||
|
||||
return bucketName + "/" + fileName;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return null; // or throw an exception
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user