无关风月
2024-12-30 4ef2de7aa7fc24ee19020330e781bae0b51b956c
common/src/main/java/com/jilongda/common/component/AliOssFileUploadController.java
@@ -41,28 +41,28 @@
    private String FILE_CDN;
    @ApiOperation(value = "单文件上传", notes = "单文件上传,rename 默认不重命名")
    @PostMapping(value = "strUpload", headers = "content-type=multipart/form-data")
    public String strUploads(@RequestParam(value = "file") MultipartFile mf) throws IOException {
        if (mf.isEmpty()) {
            return "请传入文件!";
        }
        String fileName = mf.getOriginalFilename();
        String TimeDir =new SimpleDateFormat("yyyy-MM-dd").format(new Date());
//        String realPath = "D:\\" + TimeDir;
        String realPath = "/usr/local/nginx/html/images/" + TimeDir;
        File file = new File(realPath);
        // 没有目录就创建
        if (!file.exists()) {
            file.mkdirs();
        }
        File targetFile = new File(realPath, fileName);//目标文件
        //开始从源文件拷贝到目标文件
        //传图片一步到位
        mf.transferTo(targetFile);
        //拼接数据
        return "http://eyes.chelota.com/images/" + TimeDir +"/"+ fileName;
    }
//    @ApiOperation(value = "单文件上传", notes = "单文件上传,rename 默认不重命名")
//    @PostMapping(value = "strUpload", headers = "content-type=multipart/form-data")
//    public String strUploads(@RequestParam(value = "file") MultipartFile mf) throws IOException {
//        if (mf.isEmpty()) {
//            return "请传入文件!";
//        }
//        String fileName = mf.getOriginalFilename();
//        String TimeDir =new SimpleDateFormat("yyyy-MM-dd").format(new Date());
////        String realPath = "D:\\" + TimeDir;
//        String realPath = "/usr/local/nginx/html/images/" + TimeDir;
//        File file = new File(realPath);
//        // 没有目录就创建
//        if (!file.exists()) {
//            file.mkdirs();
//        }
//        File targetFile = new File(realPath, fileName);//目标文件
//        //开始从源文件拷贝到目标文件
//        //传图片一步到位
//        mf.transferTo(targetFile);
//        //拼接数据
//        return "http://eyes.chelota.com/images/" + TimeDir +"/"+ fileName;
//    }
    @ApiOperation(value = "服务端上传", notes = "服务端上传")
    @PostMapping(value = "upload")
    public ApiResult<String> fileUpload(@RequestParam(value = "file") MultipartFile file) throws IOException {