mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
🤤release 5.8.33
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-parent</artifactId>
|
||||
<version>5.8.33</version>
|
||||
<version>5.8.34-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>hutool-extra</artifactId>
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package cn.hutool.extra.compress.archiver;
|
||||
|
||||
import cn.hutool.core.lang.Filter;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
|
@@ -268,6 +268,8 @@ public class JakartaMail implements Builder<MimeMessage> {
|
||||
if (StrUtil.startWith(attachment.getContentType(), "image/")) {
|
||||
// 图片附件,用于正文中引用图片
|
||||
bodyPart.setContentID(nameEncoded);
|
||||
// 图片附件设置内联,否则无法正常引用图片
|
||||
bodyPart.setDisposition(MimeBodyPart.INLINE);
|
||||
}
|
||||
this.multipart.addBodyPart(bodyPart);
|
||||
}
|
||||
|
@@ -8,10 +8,7 @@ import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import javax.activation.DataSource;
|
||||
import javax.activation.FileDataSource;
|
||||
import javax.activation.FileTypeMap;
|
||||
import javax.activation.*;
|
||||
import javax.mail.Address;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.Multipart;
|
||||
@@ -273,6 +270,8 @@ public class Mail implements Builder<MimeMessage> {
|
||||
if (StrUtil.startWith(attachment.getContentType(), "image/")) {
|
||||
// 图片附件,用于正文中引用图片
|
||||
bodyPart.setContentID(nameEncoded);
|
||||
// 图片附件设置内联,否则无法正常引用图片
|
||||
bodyPart.setDisposition(MimeBodyPart.INLINE);
|
||||
}
|
||||
this.multipart.addBodyPart(bodyPart);
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package cn.hutool.extra.pinyin.engine.tinypinyin;
|
||||
|
||||
import cn.hutool.core.lang.Opt;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.pinyin.PinyinEngine;
|
||||
import com.github.promeg.pinyinhelper.Pinyin;
|
||||
|
@@ -122,6 +122,19 @@ public class SpringUtil implements BeanFactoryPostProcessor, ApplicationContextA
|
||||
return getBeanFactory().getBean(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过class获取Bean
|
||||
*
|
||||
* @param <T> Bean类型
|
||||
* @param clazz Bean类
|
||||
* @param args 创建bean需要的参数属性
|
||||
* @return Bean对象
|
||||
* @since 5.8.34
|
||||
*/
|
||||
public static <T> T getBean(Class<T> clazz, Object... args) {
|
||||
return getBeanFactory().getBean(clazz, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过name,以及Clazz返回指定的Bean
|
||||
*
|
||||
@@ -134,6 +147,18 @@ public class SpringUtil implements BeanFactoryPostProcessor, ApplicationContextA
|
||||
return getBeanFactory().getBean(name, clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过name,以及Clazz返回指定的Bean
|
||||
*
|
||||
* @param name Bean名称
|
||||
* @param args 创建bean需要的参数属性
|
||||
* @return Bean对象
|
||||
* @since 5.8.34
|
||||
*/
|
||||
public static Object getBean(String name, Object... args) {
|
||||
return getBeanFactory().getBean(name, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过类型参考返回带泛型参数的Bean
|
||||
*
|
||||
|
@@ -8,13 +8,9 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.ftp.AbstractFtp;
|
||||
import cn.hutool.extra.ftp.FtpConfig;
|
||||
import cn.hutool.extra.ftp.FtpException;
|
||||
import com.jcraft.jsch.ChannelSftp;
|
||||
import com.jcraft.jsch.*;
|
||||
import com.jcraft.jsch.ChannelSftp.LsEntry;
|
||||
import com.jcraft.jsch.ChannelSftp.LsEntrySelector;
|
||||
import com.jcraft.jsch.Session;
|
||||
import com.jcraft.jsch.SftpATTRS;
|
||||
import com.jcraft.jsch.SftpException;
|
||||
import com.jcraft.jsch.SftpProgressMonitor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
@@ -111,7 +107,7 @@ public class Sftp extends AbstractFtp {
|
||||
* @since 4.1.14
|
||||
*/
|
||||
public Sftp(Session session, Charset charset) {
|
||||
super(FtpConfig.create().setCharset(charset));
|
||||
super(FtpConfig.create().setCharset(charset).setHost(session.getHost()).setPort(session.getPort()));
|
||||
init(session, charset);
|
||||
}
|
||||
|
||||
@@ -172,6 +168,17 @@ public class Sftp extends AbstractFtp {
|
||||
* @since 5.3.3
|
||||
*/
|
||||
public void init() {
|
||||
// issue#IB69U8 如果用户传入Session对象,则不能使用配置初始化,而是尝试重新连接
|
||||
if(StrUtil.isEmpty(this.ftpConfig.getHost()) && null != this.session){
|
||||
try {
|
||||
this.session.connect((int) this.ftpConfig.getConnectionTimeout());
|
||||
} catch (JSchException e) {
|
||||
throw new JschRuntimeException(e);
|
||||
}
|
||||
init(this.session, this.ftpConfig.getCharset());
|
||||
return;
|
||||
}
|
||||
|
||||
init(this.ftpConfig);
|
||||
}
|
||||
|
||||
|
@@ -38,6 +38,15 @@ public class JakartaMailTest {
|
||||
JakartaMailUtil.sendHtml("hutool@foxmail.com", "测试", "<h1>邮件来自Hutool测试</h1><img src=\"cid:testImage\" />", map);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void sendHtmlWithImageTest() {
|
||||
Map<String, InputStream> map = new HashMap<>();
|
||||
InputStream in = getClass().getClassLoader().getResourceAsStream("image/Dromara.png");
|
||||
map.put("<image-1>", in);
|
||||
JakartaMailUtil.sendHtml("hutool@foxmail.com;li7hai26@outlook.com", "测试", "<h1>邮件来自Hutool测试</h1><img src=\"cid:image-1\" />", map);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void sendHtmlTest() {
|
||||
|
@@ -38,6 +38,15 @@ public class MailTest {
|
||||
MailUtil.sendHtml("hutool@foxmail.com", "测试", "<h1>邮件来自Hutool测试</h1><img src=\"cid:testImage\" />", map);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void sendHtmlWithImageTest() {
|
||||
Map<String, InputStream> map = new HashMap<>();
|
||||
InputStream in = getClass().getClassLoader().getResourceAsStream("image/Dromara.png");
|
||||
map.put("<image-1>", in);
|
||||
MailUtil.sendHtml("hutool@foxmail.com;li7hai26@outlook.com", "测试", "<h1>邮件来自Hutool测试</h1><img src=\"cid:image-1\" />", map);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void sendHtmlTest() {
|
||||
|
BIN
hutool-extra/src/test/resources/image/Dromara.png
Normal file
BIN
hutool-extra/src/test/resources/image/Dromara.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
Reference in New Issue
Block a user