maven dependency
<!-- https://mvnrepository.com/artifact/net.coobird/thumbnailator 缩略-->
<dependency>
<groupId>net.coobird</groupId>
<artifactId>thumbnailator</artifactId>
<version>0.4.8</version>
</dependency>
<!-- SmbFile -->
<dependency>
<groupId>jcifs</groupId>
<artifactId>jcifs</artifactId>
<version>1.3.17</version>
</dependency>
上传文件
public class Test {
//从本地读取图片转成缩略图上传到服务主机中
public static void main(String[] args) {
try {
String path = "";
SmbFile uploadfile = new SmbFile("smb://asd;ay6sa:naveco:123@186.20.10.88/filename/");
path = uploadfile+"1.jpg";
OutputStream out = new SmbFileOutputStream(path);
Thumbnails.of("D://1.jpg").size(120, 120).toOutputStream(out);
} catch (IOException e) {
e.printStackTrace();
}
}
}
一个从装环境开始的学习记录公众号,欢迎大家关注: