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


边栏推荐
- 【HMS core】【Ads Kit】Huawei Advertising——Overseas applications are tested in China. Official advertisements cannot be displayed
- Shell条件语句判断
- 接口测试 Mock 实战(二) | 结合 jq 完成批量化的手工 Mock
- 数字孪生园区场景中的坐标知识
- Interface Test Framework Practice | Process Encapsulation and Test Case Design Based on Encrypted Interface
- Fluorescent marker peptides FITC/AMC/FAM/Rhodamine TAMRA/Cy3 / Cy5 / Cy7 - Peptide
- 【开发者必看】【push kit】推送服务服务典型问题合集2
- CAD有生僻字如何打出来、如何提交软件相关问题或建议?
- [Harmony OS] [ArkUI] ets development graphics and animation drawing
- JS bottom handwriting
猜你喜欢

Kotlin-Flow常用封装类:StateFlow的使用

在树莓派上搭建属于自己的网页(2)

Secondary development of WinForm controls

Shell之条件语句

RequestContextHolder

Windows 安装PostgreSQL

DFS's complement to pruning

Install PostgreSQL on Windows
![[Harmony OS] [ARK UI] ETS context basic operations](/img/40/d5924477c42e2b3246eb212f4be534.png)
[Harmony OS] [ARK UI] ETS context basic operations

Harmony OS ets ArkUI 】 【 】 the development basic page layout and data connection
随机推荐
【Harmony OS】【ARK UI】Date 基本操作
数字孪生园区场景中的坐标知识
接口测试框架实战(二)| 接口请求断言
在树莓派上搭建属于自己的网页(1)
Interface test Mock combat (2) | Combined with jq to complete batch manual Mock
接口和抽象
The problem that the rosbag tool plotjuggler cannot open rosbag
User password verification
安装IIS服务(Internet信息服务(Internet Information Services,简写IIS,互联网信息服务)
普乐蛙VR台风体验馆厂家VR防震减灾模拟VR沉浸式体验设备
typescript46-函数之间的类型兼容性
常见荧光染料修饰多种基团及其激发和发射波长数据一览数据
BIOTIN ALKYNE CAS:773888-45-2价格,供应商
【Harmony OS】【ARK UI】轻量级数据存储
Secondary development of WinForm controls
内部类、static关键字、final
刚上线就狂吸70W粉,新型商业模式“分享购”来了,你知道吗?
Interface Test Framework Practice | Process Encapsulation and Test Case Design Based on Encrypted Interface
WinForm的控件二次开发
Alienware上线首个数字时装AR试穿体验