阿里云上传

复制代码
/**
 * 上传图片
 *
 * @param file 文件
 * @return
 * @throws Exception
 */
@PostMapping(value = "/aliUpload")
@ResponseBody
public AjaxResult aliUpload(MultipartFile file){
    //获取文件后缀
    String extension = FileUploadUtils.getExtension(file);
    String imgFormat = "{}/{}/{}.{}";
    String currentDate = DateUtil.format(DateUtil.date(), "yyyy/MM/dd");
    AjaxResult ajaxResult = AjaxResult.success();
    String fileName = FileUploadUtil.uploadFile(UploadPlatform.Ali, file,
            StrUtil.format(imgFormat, "img", currentDate, RandomUtil.randomString(16),extension));
    String urlFormat = "{}/{}";
    String url = StrUtil.format(urlFormat, "img", fileName);
    ajaxResult.put("url", url);
    ajaxResult.put("fileName", fileName);
    return ajaxResult;
}

<!-- 阿里云oss依赖 -->

<dependency>

<groupId>com.aliyun.oss</groupId>

<artifactId>aliyun-sdk-oss</artifactId>

<version>3.4.2</version>

</dependency>

<!--好牛工具类-->

<dependency>

<groupId>com.github.hfhn</groupId>

<artifactId>hntool</artifactId>

<version>1.0.13</version>

</dependency>

main

复制代码
Vue.prototype.aliyunResource = function () {
  return "https://xxxxxx.oss-cn-hangzhou.aliyuncs.com/";
}
相关推荐
Arwen30317 分钟前
IP地址证书的常见问题有哪些?有没有特殊渠道可以申请免费IP证书?
服务器·网络·网络协议·tcp/ip·http·https
学编程的小程33 分钟前
从“兼容”到“超越”:金仓KESBSON引擎如何借多模融合改写文档数据库规则
数据库
千层冷面35 分钟前
数据库分库分表
java·数据库·mysql·oracle
DBA小马哥1 小时前
金仓数据库引领国产化替代新范式:构建高效、安全的文档型数据库迁移解决方案
数据库·安全·mongodb·dba·迁移学习
HIT_Weston1 小时前
100、【Ubuntu】【Hugo】搭建私人博客:元信息&翻译(一)
linux·运维·ubuntu
C_心欲无痕1 小时前
Docker 的镜像与容器
运维·docker·容器
Mr. Cao code1 小时前
Docker匿名数据卷实战指南
运维·ubuntu·docker·容器
Blossom.1181 小时前
AI Agent的长期记忆革命:基于向量遗忘曲线的动态压缩系统
运维·人工智能·python·深度学习·自动化·prompt·知识图谱
企业对冲系统官2 小时前
基差风险管理系统日志分析功能的架构与实现
大数据·网络·数据库·算法·github·动态规划
冉冰学姐2 小时前
SSM学毕电设信息采集系统74v6w(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面
数据库·学生管理·ssm 框架应用·学毕电设·信息采集系统