提交 76b3592e 编写于 作者: W worldstear

增加获取外网文件链接

上级 4965260b
......@@ -115,4 +115,16 @@ public class FileController {
IoUtil.copy(resource.getInputStream(), response.getOutputStream());
}
/**
* 获取文件外网的访问地址
* @param bucket
* @param fileName
* @return
*/
@Inner(false)
@GetMapping("/online/{bucket}/{fileName}")
public R<String> onlineFile(@PathVariable String bucket, @PathVariable String fileName) {
return R.ok(sysFileService.onlineFile(bucket, fileName));
}
}
......@@ -53,5 +53,12 @@ public interface SysFileService extends IService<SysFile> {
* @return
*/
Boolean deleteFile(Long id);
/**
* 获取外网访问地址
* @param bucket
* @param fileName
* @return
*/
String onlineFile(String bucket, String fileName);
}
......@@ -126,4 +126,15 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
this.save(sysFile);
}
/**
* 默认获取文件的在线地址
* @param bucket
* @param fileName
* @return
*/
@Override
public String onlineFile(String bucket, String fileName) {
return ossTemplate.getObjectURL(bucket, fileName, Duration.of(7, ChronoUnit.DAYS));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册