Pu Zhibing
2024-10-10 19d2b6427ebed89895b402d5e61ab78f4687b550
UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/UserInfoController.java
@@ -1181,12 +1181,12 @@
    @ResponseBody
    @RequestMapping("/base/user/image")
    public String image(@RequestPart("file") MultipartFile file) {
    public ResultUtil image(@RequestPart("file") MultipartFile file) {
        try {
            String pictureName = GoogleCloudStorageUtil.upload(file);
            return pictureName;
            return ResultUtil.success(pictureName);
        } catch (Exception e1) {
            return null;
            return ResultUtil.runErr();
        }
    }
@@ -1398,14 +1398,21 @@
            new Timer().schedule(new TimerTask() {
                @Override
                public void run() {
                    Process process = null;
                    try {
                        process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName + ".mp3");
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                    if (process != null) {
                        process.destroy();
                        // 使用Runtime执行命令
                        Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName + ".mp3");
                        // 读取命令的输出
                        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
                        String line;
                        while ((line = reader.readLine()) != null) {
                            System.out.println(line);
                        }
                        // 等待命令执行完成
                        process.waitFor();
                        // 关闭流
                        reader.close();
                    } catch (IOException | InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }, 30000);