首页 文章 精选 留言 我的

精选列表

搜索[分布式存储],共10012篇文章
优秀的个人博客,低调大师

JEESZ分布式架构集成阿里云OSS存储

摘要: 1. 服务接口定义 /** * 文件上传 1:头像 2:显示图片 3:个人封面 :4:基础图片 * @param request * @param response * @param uid 用户id * @param userType 文件上传 1:头像 2:显示图片 3:个人封面 :4:基础图片 0:视频 * @param files 上传的文件对象 * @return 1. 服务接口定义 /** * 文件上传 1:头像 2:显示图片 3:个人封面 :4:基础图片 *@paramrequest *@paramresponse *@paramuid 用户id *@paramuserType 文件上传 1:头像 2:显示图片 3:个人封面 :4:基础图片 0:视频 *@paramfiles 上传的文件对象 * @return * @throws Exception */ @RequestMapping(value = "/upload/base64Code", method = RequestMethod.POST) public ResponseVO fileuploadBase64(@RequestBody JSONObject json, HttpServletRequest request, HttpServletResponse response) throws Exception { String uid = json.optString("uid"); String userType = json.optString("userType"); String base64Code = json.optString("base64Code"); String oldName = json.optString("oldName"); String suffix = json.optString("suffix"); //获取当前登陆用户 if(StringUtils.isEmpty(uid)){ return CloudResponseCode.buildEnumResponseVO(CloudResponseCode.USER_ID_NOT_NULL, null); } //上传文件新名字 String newName = String.valueOf(new Date().getTime()); String fileKey = CloudConstant.VITAL_USER_INFO_PATH + uid + "/" + newName + "." + suffix; AliyunUtils.getInstance().uploadByte(base64Code.getBytes(), fileKey); ...... ....... return CloudResponseCode.buildEnumResponseVO(CloudResponseCode.FILEUPLOAD_SUCCESS, obj); } 2. oss utils封装 /** * 上传byte数组 * @param fileByte * @param fileKey */ public void uploadByte(byte[] fileByte, String fileKey){ // 创建OSSClient实例 OSSClient ossClient = new OSSClient(CloudConstant.ENDPOINT, CloudConstant.ACCESSKEYID, CloudConstant.ACCESSKEYSECRET); // 上传byte数组 ossClient.putObject(CloudConstant.BUCKET, fileKey, new ByteArrayInputStream(fileByte)); // 关闭client ossClient.shutdown(); } /** * 上传文件流 * @param inputStream * @param fileKey */ public void uploadInputStream(InputStream inputStream, String fileKey){ // 创建OSSClient实例 OSSClient ossClient = new OSSClient(CloudConstant.ENDPOINT, CloudConstant.ACCESSKEYID, CloudConstant.ACCESSKEYSECRET); // 上传文件流 ossClient.putObject(CloudConstant.BUCKET, fileKey, inputStream); // 关闭client ossClient.shutdown(); } /** * 删除文件 * @param fileKey */ public void deleteFile(String fileKey){ // 创建OSSClient实例 OSSClient ossClient = new OSSClient(CloudConstant.ENDPOINT, CloudConstant.ACCESSKEYID, CloudConstant.ACCESSKEYSECRET); // 删除文件 ossClient.deleteObject(CloudConstant.BUCKET, fileKey); // 关闭client ossClient.shutdown(); } 3.界面效果

优秀的个人博客,低调大师

J2EE分布式架构集成阿里云OSS存储

服务接口定义 /** 文件上传 1:头像 2:显示图片 3:个人封面 :4:基础图片 @param request @param response @param uid 用户id @param userType 文件上传 1:头像 2:显示图片 3:个人封面 :4:基础图片 0:视频 @param files 上传的文件对象 @return @throws Exception */ @RequestMapping(value = "/upload/base64Code", method = RequestMethod.POST) public ResponseVO fileuploadBase64(@RequestBody JSONObject json, HttpServletRequest request, HttpServletResponse response) throws Exception { String uid = json.optString("uid"); String userType = json.optString("userType"); String base64Code = json.optString("base64Code"); String oldName = json.optString("oldName"); String suffix = json.optString("suffix"); //获取当前登陆用户 if(StringUtils.isEmpty(uid)){ return CloudResponseCode.buildEnumResponseVO(CloudResponseCode.USER_ID_NOT_NULL, null); } //上传文件新名字 String newName = String.valueOf(new Date().getTime()); String fileKey = CloudConstant.VITAL_USER_INFO_PATH + uid + "/" + newName + "." + suffix; AliyunUtils.getInstance().uploadByte(base64Code.getBytes(), fileKey); ...... ....... return CloudResponseCode.buildEnumResponseVO(CloudResponseCode.FILEUPLOAD_SUCCESS, obj); } oss utils封装 /** 上传byte数组 @param fileByte @param fileKey */ public void uploadByte(byte[] fileByte, String fileKey){ // 创建OSSClient实例 OSSClient ossClient = new OSSClient(CloudConstant.ENDPOINT, CloudConstant.ACCESSKEYID, CloudConstant.ACCESSKEYSECRET); // 上传byte数组 ossClient.putObject(CloudConstant.BUCKET, fileKey, new ByteArrayInputStream(fileByte)); // 关闭client ossClient.shutdown(); } /** 上传文件流 @param inputStream @param fileKey */ public void uploadInputStream(InputStream inputStream, String fileKey){ // 创建OSSClient实例 OSSClient ossClient = new OSSClient(CloudConstant.ENDPOINT, CloudConstant.ACCESSKEYID, CloudConstant.ACCESSKEYSECRET); // 上传文件流 ossClient.putObject(CloudConstant.BUCKET, fileKey, inputStream); // 关闭client ossClient.shutdown(); } /** 删除文件 @param fileKey */ public void deleteFile(String fileKey){ // 创建OSSClient实例 OSSClient ossClient = new OSSClient(CloudConstant.ENDPOINT, CloudConstant.ACCESSKEYID, CloudConstant.ACCESSKEYSECRET); // 删除文件 ossClient.deleteObject(CloudConstant.BUCKET, fileKey); // 关闭client ossClient.shutdown(); } 界面效果

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册