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);
}
}
}
}
本文展示了如何在Java应用中使用FastDFS进行文件下载(M00/00/57/JIWsB2SJgJWAQdavAAM-xxxxx.png)和图片上传,包括创建StorePath对象并处理异常。
1898

被折叠的 条评论
为什么被折叠?



