diff --git a/src/main/java/com/alibaba/excel/converters/url/UrlImageConverter.java b/src/main/java/com/alibaba/excel/converters/url/UrlImageConverter.java index b622d66d..d178a5e9 100644 --- a/src/main/java/com/alibaba/excel/converters/url/UrlImageConverter.java +++ b/src/main/java/com/alibaba/excel/converters/url/UrlImageConverter.java @@ -3,6 +3,7 @@ package com.alibaba.excel.converters.url; import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.net.URLConnection; import com.alibaba.excel.converters.Converter; import com.alibaba.excel.enums.CellDataTypeEnum; @@ -39,8 +40,12 @@ public class UrlImageConverter implements Converter { GlobalConfiguration globalConfiguration) throws IOException { InputStream inputStream = null; try { - inputStream = value.openStream(); - byte[] bytes = IoUtils.toByteArray(inputStream); + + URLConnection conn = value.openConnection(); + conn.setConnectTimeout(1000); + conn.setReadTimeout(5000); + inputStream = con.getInputStream(); + byte[] bytes = IoUtils.toByteArray(inputStream); return new CellData(bytes); } finally { if (inputStream != null) {