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


边栏推荐
- 接口管理工具YApi怎么用?颜值高、易管理、超好用
- GIS数据漫谈(五)— 地理坐标系统
- 数据库基本概述与SQL概述
- Talking about GIS Data (6) - Projected Coordinate System
- 力扣561. 数组拆分
- 用户密码验证
- 【Harmony OS】【ARK UI】ETS 上下文基本操作
- 【Harmony OS】【FAQ】鸿蒙问题合集1
- Interface test practice | Detailed explanation of the difference between GET / POST requests
- Peptides mediated PEG DSPE of phospholipids, targeted functional materials - PEG - RGD/TAT/NGR/APRPG
猜你喜欢

高可用 两地三中心

荧光标记多肽FITC/AMC/FAM/Rhodamine/TAMRA/Cy3/Cy5/Cy7-Peptide

OSI的分层特点、传输过程与三次握手、四次挥手、tcp与udp包头的描述

【Harmony OS】【FAQ】Hongmeng Questions Collection 1

IO process thread -> thread -> day5

【 Harmony OS 】 【 ano UI 】 lightweight data storage

接口和抽象

【Harmony OS】【ARK UI】ETS 上下文基本操作

GIS数据漫谈(五)— 地理坐标系统

多肽介导PEG磷脂——靶向功能材料之DSPE-PEG-RGD/TAT/NGR/APRPG
随机推荐
荧光标记多肽FITC/AMC/FAM/Rhodamine/TAMRA/Cy3/Cy5/Cy7-Peptide
typescript43-类型兼容性说明
自组织是管理者和成员的双向奔赴
【开发者必看】【push kit】推送服务服务典型问题合集2
unity2D横板游戏教程6-敌人AI以及受击动画
探索性测试的概念及方法
MySQL 出现 The table is full 的解决方法
Unity2D horizontal board game tutorial 6 - enemy AI and attack animation
How to prepare for the test interface test data
软件开发的最大的区别是什么?
【Harmony OS】【ARK UI】Date 基本操作
私域流量引流方法?分享购火爆的商业模式,你值得拥有
接口测试实战| GET/POST 请求区别详解
IO进程线程->线程->day5
js garbage collection mechanism
Harmony OS ets ArkUI 】 【 】 the development basic page layout and data connection
测试人员的价值体现在哪里
rosbag工具plotjuggler无法打开rosbag的问题
在竞争白热化的电商行业,链动2+1为什么还有企业在用
typescript46-函数之间的类型兼容性