mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-23 13:03:42 +08:00
增加获取外网文件链接
This commit is contained in:
parent
4965260b62
commit
76b3592e1d
@ -115,4 +115,16 @@ public class FileController {
|
|||||||
IoUtil.copy(resource.getInputStream(), response.getOutputStream());
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -54,4 +54,11 @@ public interface SysFileService extends IService<SysFile> {
|
|||||||
*/
|
*/
|
||||||
Boolean deleteFile(Long id);
|
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);
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user