1. 文件上传到本地
- 实现方式
Spring MVC使用commons-fileupload实现文件上传,注意事项如下:
l HTTP请求方法是POST。
l HTTP请求头的Content-Type是multipart/form-data。
- SpringMVC配置
配置commons-fileupload插件的文件上传解析器CommonsMultipartResolver,id是multipartResolver。
2. 文件上传到阿里云OSS
- 阿里云计算相关简介
阿里云计算平台提供了包括弹性计算、存储、网络、安全、大数据等一系列的云计算基础设施和应用服务。阿里云以其高可用性、可靠性和灵活性,成为许多企业和开发者选择的云平台之一。可通过阿里云-计算,为了无法计算的价值进行访问和操作。

- 对象存储OSS相关简介
阿里云对象存储 OSS(Object Storage Service)是一款海量、安全、低成本、高可靠的云存储服务。

- 阿里云OSS可视化操作

3. Spring MVC文件上传案例
基于Spring MVC实现文件上传:
-
使用commons-fileupload实现文件上传到本地目录。
-
实现上传文件到阿里云OSS和从阿里云OSS下载文件到本地。
案例实现详见链接:案例14 Spring MVC文件上传案例