FastDFS整合部分省略......
在这里插入代码片
@Autowired
private FastFileStorageClient fastFileStorageClient;
@Override
public void testFastDFS() {
FileOutputStream out = null;
ByteArrayInputStream inputStream = null;
try {
StorePath storePath = new StorePath("group1", "M00/00/57/JIWsB2SJgJWAQdavAAM-xxxxx.png");
byte[] bytes = fastFileStorageClient.downloadFile(storePath.getGroup(), storePath.getPath(), new DownloadByteArray());
inputStream = new ByteArrayInputStream(bytes);
StorePath storePathUpload = fastFileStorageClient.uploadImageAndCrtThumbImage( inputStream,
inputStream.available(), "png", null);
} catch (Exception e) {
throw new RuntimeException(e);
}finally {
if(out != null ){
try {
out.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
if(inputStream != null){
try {
inputStream.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
}