当前位置:网站首页>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.


边栏推荐
- Flink state
- 数字孪生园区场景中的坐标知识
- Shell条件语句判断
- Two ways to simulate multi-user login in Jmeter
- 数字化时代,企业如何建立自身的云平台与商业模式的选择?
- Interface test practice | Detailed explanation of the difference between GET / POST requests
- typescript49-交叉类型
- 接口测试实战| GET/POST 请求区别详解
- typescript44-对象之间的类兼容器
- Talking about GIS Data (5) - Geographic Coordinate System
猜你喜欢

Shell conditional statement judgment

修饰生物素DIAZO-生物素-PEG3-DBCO|重氮-生物素-三聚乙二醇-二苯基环辛炔

Interface Test Framework Practice (4) | Get Schema Assertion

高可用 两地三中心

常见亲脂性细胞膜染料DiO, Dil, DiR, Did光谱图和实验操作流程

Coordinate knowledge in digital twin campus scenarios

Talking about GIS Data (6) - Projected Coordinate System

Unity2D horizontal board game tutorial 6 - enemy AI and attack animation

typescript41-class类的私有修饰符

typescript40-class类的保护修饰符
随机推荐
Modified BiotinDIAZO-Biotin-PEG3-DBCO|diazo-biotin-tripolyethylene glycol-diphenylcyclooctyne
安装IIS服务(Internet信息服务(Internet Information Services,简写IIS,互联网信息服务)
MOSN 反向通道详解
How to prepare for the test interface test data
typescript42-readonly修饰符
Peptides mediated PEG DSPE of phospholipids, targeted functional materials - PEG - RGD/TAT/NGR/APRPG
移动流量的爆发式增长,社交电商如何选择商业模式
13.< tag-动态规划和回文字串>lt.647. 回文子串 + lt.516.最长回文子序列
社交电商:流量红利已尽,裂变营销是最低成本的获客之道
Concepts and Methods of Exploratory Testing
js的垃圾回收机制
接口测试如何准备测试数据
Create a tree structure
GIS数据漫谈(五)— 地理坐标系统
rosbag工具plotjuggler无法打开rosbag的问题
【生物素叠氮化物|cas:908007-17-0】价格_厂家
技术分享 | 接口自动化测试中如何对xml 格式做断言验证?
Apache DolphinScheduler版本2.0.5分布式集群的安装
探索性测试的概念及方法
Super handy drawing tool is recommended