新版仿ok交易所-后端
1
zj
8 days ago 579177ac64462d0fec885eb10af3097245134f80
trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiUploadFileController.java
@@ -3,6 +3,7 @@
import com.yami.trading.bean.model.FileUploadParamsModel;
import com.yami.trading.bean.vo.FileInfoVo;
import com.yami.trading.common.constants.Constants;
import com.yami.trading.common.domain.Result;
import com.yami.trading.common.exception.YamiShopBindException;
import com.yami.trading.service.AwsS3OSSFileService;
@@ -27,17 +28,17 @@
    public Result uploadFile(FileUploadParamsModel model) {
        try {
            if (model.getFile().getSize() / 1000L > 4500) {
               throw  new YamiShopBindException("图片大小不能超过4M");
               throw  new YamiShopBindException("Image size cannot exceed 4MB");
            }
            String path=  awsS3OSSFileService.uploadFile(model.getModuleName(), model.getFile());
            FileInfoVo fileInfoVo=new FileInfoVo();
            fileInfoVo.setHttpUrl(awsS3OSSFileService.getUrl(path));
            fileInfoVo.setHttpUrl(Constants.IMAGES_HTTP+path);
            fileInfoVo.setPath(path);
            return Result.succeed(fileInfoVo);
        }
         catch (Exception e) {
             e.printStackTrace();
            throw  new YamiShopBindException("文件上传失败");
            throw  new YamiShopBindException("File upload failed");
        }
    }
}