阿里云上传

复制代码
/**
 * 上传图片
 *
 * @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/";
}
相关推荐
Absurd5874 小时前
JavaScript中模块化在游戏引擎开发中的资源调度作用
jvm·数据库·python
2301_815279525 小时前
SQL如何利用聚合函数生成业务分析指标_KPI计算基础教程
jvm·数据库·python
qq_330037995 小时前
mysql如何排查Out of memory错误_mysql内存分配调优
jvm·数据库·python
weixin_458580126 小时前
如何在 Go 中直接将 AST 编译为可执行二进制文件?
jvm·数据库·python
Highcharts.js8 小时前
Highcharts Grid 中文站正式上线:表格数据处理的全新选择
前端·javascript·数据库·表格数据·highcharts·可视化图表·企业级图表
Elastic 中国社区官方博客11 小时前
Elasticsearch:使用 Agent Builder 的 A2A 实现 - 开发者的圣诞颂歌
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
2301_8166602111 小时前
PHP怎么处理Eloquent Attribute Inference属性推断_Laravel从数据自动推导类型【操作】
jvm·数据库·python
qq_3721542312 小时前
Go 中自定义类型与基础类型的显式转换规则详解
jvm·数据库·python
_下雨天.13 小时前
NoSQL之Redis配置与优化
数据库·redis·nosql
LiAo_1996_Y13 小时前
CSS如何实现文字渐变效果_通过background-clip实现艺术字
jvm·数据库·python