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


边栏推荐
猜你喜欢
![[Harmony OS] [ARK UI] ETS context basic operations](/img/40/d5924477c42e2b3246eb212f4be534.png)
[Harmony OS] [ARK UI] ETS context basic operations

接口测试实战| GET/POST 请求区别详解

Talking about GIS Data (5) - Geographic Coordinate System

DFS对剪枝的补充

【Biotin Azide|cas:908007-17-0】Price_Manufacturer

Two ways to simulate multi-user login in Jmeter

【Harmony OS】【ArkUI】ets开发 图形与动画绘制

Exception(异常) 和 Error(错误)区别解析

GIS数据漫谈(六)— 投影坐标系统

UV decomposition of biotin - PEG2 - azide | CAS: 1192802-98-4 biotin connectors
随机推荐
2022暑假牛客多校联赛第一场
JS底层手写
【HMS core】【Ads Kit】华为广告——海外应用在国内测试正式广告无法展示
Apache DolphinScheduler版本2.0.5分布式集群的安装
MCM box model modeling method and source analysis of atmospheric O3
UV decomposition of biotin - PEG2 - azide | CAS: 1192802-98-4 biotin connectors
1.一个神经网络示例
【 Harmony OS 】 【 ano UI 】 lightweight data storage
用户密码加密工具
【Biotin Azide|cas:908007-17-0】Price_Manufacturer
UV 裂解的生物素-PEG2-叠氮|CAS:1192802-98-4生物素接头
DFS's complement to pruning
shell script loop statement
常见荧光染料修饰多种基团及其激发和发射波长数据一览数据
Shell conditional statement judgment
Windows 安装PostgreSQL
Online password generator tool recommendation
在树莓派上搭建属于自己的网页(1)
DDL操作数据库、表、列
Redis连接不上的报错解决方案汇总