当前位置:网站首页>Ali cloud object storage oss private barrels to generate links
Ali cloud object storage oss private barrels to generate links
2022-08-03 05:11:00 【Code Valley Girl of the Unknown】
Business Scenario:
1, you need to download files from other platforms and upload them to oss object storage.
2, the app side needs thumbnail display of small images, including video clips.
3, secure access and memory regulation, etc.
4, chat platform conversion, etc.
Object storage helps us store files, data, more secure and faster.
Alibaba Cloud OSS address:
We use link conversion through private bucket encryption to generate valid links based on time.
/*** Get the url address of the signed file by uploading** @param ossClient* @param key* @return*/public static String getFileUrl(OSS ossClient, String key, String bucketName) throws ParseException {Date date = new Date();Calendar cal = Calendar.getInstance();cal.setTime(date);//add a yearcal.add(Calendar.YEAR, 1);GeneratePresignedUrlRequest generatePresignedUrlRequest;generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucketName, key);generatePresignedUrlRequest.setExpiration(cal.getTime());URL url = ossClient.generatePresignedUrl(generatePresignedUrlRequest);return url.toString();}
Image thumbnails and video thumbnails
GeneratePresignedUrlRequest generatePresignedUrlRequest;generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucketName, key);generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucketName, key);generatePresignedUrlRequest.setExpiration(cal.getTime());generatePresignedUrlRequest.setProcess(wechatConfig.getLargerImgStyle());URL largerImgUrl = ossClient.generatePresignedUrl(generatePresignedUrlRequest);#big picture thumbnaillarger_img_style: image/resize,l_720#Thumbnailthumbnail_img_style: image/resize,l_198#video thumbnailvideo_style: video/snapshot,t_50000,f_jpg,w_800,h_600// video thumbnail// Create an OSSClient instance.GeneratePresignedUrlRequest req = new GeneratePresignedUrlRequest(bucketName, key, HttpMethod.GET);req.setExpiration(cal.getTime());req.setProcess(wechatConfig.getVideoStyle());URL signedUrl = ossClient.generatePresignedUrl(req);
We can familiarize ourselves with the setProcess settings. Alibaba Cloud's official website also has detailed reference and tutorials.
边栏推荐
猜你喜欢
数字化时代,企业如何建立自身的云平台与商业模式的选择?
Talking about GIS Data (6) - Projected Coordinate System
常见亲脂性细胞膜染料DiO, Dil, DiR, Did光谱图和实验操作流程
Bubble sort in c language structure
unity2D横板游戏教程6-敌人AI以及受击动画
Modified BiotinDIAZO-Biotin-PEG3-DBCO|diazo-biotin-tripolyethylene glycol-diphenylcyclooctyne
shell脚本循环语句
MCM箱模型建模方法及大气O3来源解析
Two ways to simulate multi-user login in Jmeter
接口和协议
随机推荐
Peptides mediated PEG DSPE of phospholipids, targeted functional materials - PEG - RGD/TAT/NGR/APRPG
Kotlin-Flow常用封装类:StateFlow的使用
【软件工程之美 - 专栏笔记】35 | 版本发布:软件上线只是新的开始
Tributyl-mercaptophosphane "tBuBrettPhos Pd(allyl)" OTf), 1798782-17-8
数字孪生园区场景中的坐标知识
Talking about GIS Data (6) - Projected Coordinate System
redis键值出现 xacxedx00x05tx00&的解决方法
Windows 安装PostgreSQL
How to use the interface management tool YApi?Beautiful, easy to manage, super easy to use
tag单调栈-单调栈预备知识-lt.739. 每日温度
链动2+1模式简单,奖励结构丰厚,自主裂变?
常见亲脂性细胞膜染料DiO, Dil, DiR, Did光谱图和实验操作流程
社交电商:流量红利已尽,裂变营销是最低成本的获客之道
MySQL 删除表数据,重置自增 id 为 0 的两个方式
[Harmony OS] [ARK UI] ETS context basic operations
Get the Ip tool class
typescript41-class类的私有修饰符
[Harmony OS] [ArkUI] ets development graphics and animation drawing
Flink state
CobalStrike(CS)基础超级详细版