Java OpenResty Spring Spring Boot MySQL Redis MongoDB PostgreSQL Linux Android Nginx 面试 小程序 Arthas JVM AQS juc Kubernetes Docker DevOps


Spring Boot Undertow 上传文件后没有可读权限

Java Spring Boot Undertow 大约 601 字

现象

Undertow 上传文件至 Nginx 静态服务器后发现 group 和 other 没有读写权限

设置权限,伪代码

MultipartFile file;

String pathname = "/home/pic/aaa.jpg";
File f = new File(pathname);
file.transferTo(f);
log.info("transfer to: " + pathname);

Set<PosixFilePermission> perms = new HashSet<>();
perms.add(PosixFilePermission.OWNER_READ);
perms.add(PosixFilePermission.OWNER_WRITE);
perms.add(PosixFilePermission.GROUP_READ);
perms.add(PosixFilePermission.OTHERS_READ);
//Set<PosixFilePermission> permissions = PosixFilePermissions.fromString("rw-r--r--");
Files.setPosixFilePermissions(Paths.get(pathname), perms);
阅读 3996 · 发布于 2019-04-08

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb

扫描下方二维码关注公众号和小程序↓↓↓

扫描二维码关注我
昵称:
随便看看 换一批