|
@@ -22,14 +22,12 @@ import java.util.Date;
|
|
|
@RequestMapping("/image")
|
|
|
public class ImagesTest {
|
|
|
|
|
|
- @Value("${img.port}")
|
|
|
- public static Integer port;
|
|
|
@PostMapping("/test")
|
|
|
- public String test( @RequestParam("image") MultipartFile image ){
|
|
|
+ public String test( @RequestParam("image") MultipartFile image ) {
|
|
|
String imgname = "成功";
|
|
|
String originalFilename = image.getOriginalFilename();
|
|
|
String filenameExtension = StringUtils.getFilenameExtension(originalFilename);
|
|
|
- String path = DateUtil.format(new Date(),"yyyy-MM");
|
|
|
+ String path = DateUtil.format(new Date(), "yyyy-MM");
|
|
|
try {
|
|
|
InputStream inputStream = image.getInputStream();
|
|
|
BufferedInputStream in = new BufferedInputStream(inputStream);
|
|
@@ -42,35 +40,14 @@ public class ImagesTest {
|
|
|
}
|
|
|
in.close();
|
|
|
byte[] content = out.toByteArray();
|
|
|
- imgname =UUID.randomUUID()+"."+filenameExtension;
|
|
|
- UploadImage.sshSftp(content,path, imgname);
|
|
|
+ imgname = UUID.randomUUID() + "." + filenameExtension;
|
|
|
+ UploadImage.sshSftp(content, path, imgname);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- String content = "http://139.9.167.178/images"+path +"/"+imgname;
|
|
|
+// String content = "http://139.9.167.178/images" + path + "/" + imgname;
|
|
|
+ String content = "https://img.ifarmcloud.com/images/" + path + "/" + imgname;
|
|
|
|
|
|
return content;
|
|
|
-// byte[] key = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue()).getEncoded();
|
|
|
-// System.out.println(key);
|
|
|
-
|
|
|
-//构建
|
|
|
-// SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, key);
|
|
|
-//加密为16进制表示
|
|
|
- // aes.encryptHex(content);
|
|
|
- // System.out.println(encryptHex);
|
|
|
-////解密为字符串
|
|
|
-// String decryptStr = aes.decryptStr(encryptHex, CharsetUtil.CHARSET_UTF_8);
|
|
|
-// System.out.println(decryptStr);
|
|
|
-// return aes.encryptHex(content);
|
|
|
}
|
|
|
-
|
|
|
-// public static void main(String[] args) {
|
|
|
-//
|
|
|
-// String content = "http://139.9.167.178/images";
|
|
|
-// MD5 md5 = MD5.create();
|
|
|
-// String s = md5.digestHex16(content);
|
|
|
-// System.out.println(s);
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
}
|