|
|
@ -18,6 +18,9 @@ import com.alibaba.excel.util.IoUtils; |
|
|
|
* @since 2.1.1 |
|
|
|
* @since 2.1.1 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class UrlImageConverter implements Converter<URL> { |
|
|
|
public class UrlImageConverter implements Converter<URL> { |
|
|
|
|
|
|
|
public static int urlConnectTimeout = 1000; |
|
|
|
|
|
|
|
public static int urlReadTimeout = 5000; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Class<?> supportJavaTypeKey() { |
|
|
|
public Class<?> supportJavaTypeKey() { |
|
|
|
return URL.class; |
|
|
|
return URL.class; |
|
|
@ -28,10 +31,10 @@ public class UrlImageConverter implements Converter<URL> { |
|
|
|
GlobalConfiguration globalConfiguration) throws IOException { |
|
|
|
GlobalConfiguration globalConfiguration) throws IOException { |
|
|
|
InputStream inputStream = null; |
|
|
|
InputStream inputStream = null; |
|
|
|
try { |
|
|
|
try { |
|
|
|
URLConnection conn = value.openConnection(); |
|
|
|
URLConnection urlConnection = value.openConnection(); |
|
|
|
conn.setConnectTimeout(1000); |
|
|
|
urlConnection.setConnectTimeout(urlConnectTimeout); |
|
|
|
conn.setReadTimeout(5000); |
|
|
|
urlConnection.setReadTimeout(urlReadTimeout); |
|
|
|
inputStream = con.getInputStream(); |
|
|
|
inputStream = urlConnection.getInputStream(); |
|
|
|
byte[] bytes = IoUtils.toByteArray(inputStream); |
|
|
|
byte[] bytes = IoUtils.toByteArray(inputStream); |
|
|
|
return new WriteCellData<>(bytes); |
|
|
|
return new WriteCellData<>(bytes); |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|