Comments (4)
这里没提供java示例,可以参照php发个请求获取。
from cos-js-sdk-v5.
php的流程走通了,主要后台是Java。
看来还是要得研究php的,自己写个。
哈哈,是不是太懒了。
$qSignAlgorithm = 'sha1';
$qAk = $SecretId;
$qSignTime = $now . ';' . $expired;
$qKeyTime = $now . ';' . $expired;
$qHeaderList = strtolower(implode(';', getObjectKeys($headers)));
$qUrlParamList = strtolower(implode(';', getObjectKeys($query)));
// 签名算法说明文档:https://www.qcloud.com/document/product/436/7778
// 步骤一:计算 SignKey
$signKey = hash_hmac("sha1", $qKeyTime, $SecretKey);
// 步骤二:构成 FormatString
$formatString = implode("\n", array(strtolower($method), $pathname, obj2str($query), obj2str($headers), ''));
header('x-test-method', $method);
header('x-test-pathname', $pathname);
// 步骤三:计算 StringToSign
$stringToSign = implode("\n", array('sha1', $qSignTime, sha1($formatString), ''));
// 步骤四:计算 Signature
$qSignature = hash_hmac('sha1', $stringToSign, $signKey);
// 步骤五:构造 Authorization
$authorization = implode('&', array(
'q-sign-algorithm=' . $qSignAlgorithm,
'q-ak=' . $qAk,
'q-sign-time=' . $qSignTime,
'q-key-time=' . $qKeyTime,
'q-header-list=' . $qHeaderList,
'q-url-param-list=' . $qUrlParamList,
'q-signature=' . $qSignature
));
from cos-js-sdk-v5.
可以自行参照 php 写一个获取临时密钥的请求,拿到临时密钥后,传给 java sdk 计算签名,
再返回给前端
from cos-js-sdk-v5.
Java SDK里面有获取临时密钥的方法(getFederationToken),
然后使用SDK里面的buildAuthorizationStr可以生成authorization。
from cos-js-sdk-v5.
Related Issues (20)
- cos-js-sdk-v5 打包出错了 HOT 6
- @xmldom/xmldom 包更新 HOT 2
- 使用官方 cos.uploadFiles 导致频繁调用 getAuthorization HOT 5
- ts doc HOT 2
- CI 调用审核的文本接口提示无权限 HOT 1
- 使用 vite 打包时 出现警告 HOT 1
- getAuthorization方法callback返回ScopeLimit为true是分片上传频繁重新获取这个合理? HOT 1
- 使用 Nodejs 引入包后出现 ReferenceError: self is not defined HOT 2
- 如何读取私读权限的文件 HOT 2
- Windows Defender 再次报毒:Exploit:JS/Blacole.IE HOT 6
- 这行里有个打错的注释 HOT 1
- 1.4.15升级到1.4.17运行报错,降级到1.4.16后正常 HOT 1
- 使用import引入cos-js-sdk-v5提示can't not found name 'Buffer' HOT 2
- cos-js-sdk-v5.js:1834 Uncaught (in promise) EvalError: Refused to evaluate a string as JavaScript HOT 1
- 调用uploadFile,为什么返回了BucketAlreadyOwnedByYou: Your previous request to create the named bucket succeeded and you already own it HOT 5
- 此处是不是有问题,文档提示需要必填字段FIlePath(版本是2.13.5) HOT 1
- 关于前端上传callback HOT 6
- 导致F2 控制台卡死 HOT 1
- 继续上传的逻辑问题 HOT 1
- 触发分块上传时就会报403错误 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cos-js-sdk-v5.