修改BUG
This commit is contained in:
parent
b654c0317f
commit
15d3fe15c5
@ -12,9 +12,13 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.util.UriComponents;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
|
||||
@ -211,12 +215,11 @@ public class HttpUtils {
|
||||
* 转换base64
|
||||
* */
|
||||
public static String getImageAsBase64(String imageUrl) throws IOException {
|
||||
HttpResponse response = HttpRequest.get(imageUrl).execute();
|
||||
if (response.isOk()) {
|
||||
byte[] imageBytes = response.bodyBytes();
|
||||
return Base64.encode(imageBytes);
|
||||
} else {
|
||||
throw new IOException("Failed to fetch image, HTTP status code: " + response.getStatus());
|
||||
}
|
||||
URL url = new URL(imageUrl);
|
||||
BufferedImage image = ImageIO.read(url);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ImageIO.write(image, "png", baos);
|
||||
byte[] imageBytes = baos.toByteArray();
|
||||
return Base64.encode(imageBytes);
|
||||
}
|
||||
}
|
||||
|
||||
@ -939,7 +939,7 @@ public class InspectPatientController {
|
||||
}
|
||||
list.add(inspectPatientitemsSaveReqVO);
|
||||
patientitemsService.updatePatientitemInfo(list);
|
||||
if(dataMap.get("personimg") != null|| dataMap.get("personimg") != "")
|
||||
if(dataMap.get("personimg") != null)
|
||||
{
|
||||
String headurl = dataMap.get("personimg").toString();
|
||||
String base64 = HttpUtils.getImageAsBase64(headurl);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user