-
Notifications
You must be signed in to change notification settings - Fork 567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
服务器签名这一块代码有没有sdk #22
Comments
有的,近期优化这个demo。 |
@carsonxu 有php版本的吗 |
PHP: |
本项目readme上的这段获取授权和qcloud文档上的有什么区别,两端代码分别请求的后端是sts.php和sts-auth.php; 所用到的参数也不完全相同,我是需要按照官方文档上的来还是本项目的demo来 var cos = new COS({
getAuthorization: function (options, callback) {
var url = '../server/sts.php';
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onload = function (e) {
try {
var data = JSON.parse(e.target.responseText);
} catch (e) {
}
callback({
TmpSecretId: data.credentials && data.credentials.tmpSecretId,
TmpSecretKey: data.credentials && data.credentials.tmpSecretKey,
XCosSecurityToken: data.credentials && data.credentials.sessionToken,
ExpiredTime: data.expiredTime,
});
};
xhr.send();
}
}); https://cloud.tencent.com/document/product/436/9067 xhr.onload = function (e) {
var AuthData;
try {
AuthData = JSON.parse(xhr.responseText)
} catch (e) {}
if (AuthData && AuthData.Authorization) {
callback(null, {
Authorization: AuthData.Authorization,
XCosSecurityToken: AuthData.XCosSecurityToken,
});
} else {
console.error(AuthData);
callback('获取签名出错');
}
};
xhr.onerror = function (e) {
callback('获取签名出错');
}; |
我按照cloud,tencent。com 的上面的例子去写,得到这么个结果: <?xml version='1.0' encoding='utf-8' ?>
<Error>
<Code>RequestTimeTooSkewed</Code>
<Message>The difference between the request time and the current time is too large.</Message>
<Resource>phpdish-1251726071.cos.ap-beijing.myqcloud.com</Resource>
<RequestId>NWIxZjVlMGNfZDI4NWQ2NF8yMDY2MV8yYjE3M2I=</RequestId>
<TraceId>OGVmYzZiMmQzYjA2OWNhODk0NTRkMTBiOWVmMDAxODc0OWRkZjk0ZDM1NmI1M2E2MTRlY2MzZDhmNmI5MWI1OTBjYzE2MjAxN2M1MzJiOTdkZjMxMDVlYTZjN2FiMmI0NGYxMTg3ODZiZjg0NjU3NjRlMmYxZWMxZmQwZDM2NGU=</TraceId>
</Error> 麻烦给看下是什么原因。 |
你好, 后端获取临时秘钥再返回给客户端, 客户端直接拿着秘钥就可以调用云存储的接口上传图片了, 那这里面的生成签名是干嘛用的?为啥还要生成签名 |
@luoshuisheng 这里是前端如果不想用SDK,不方便计算签名,就可以让服务端计算好签名给前端用。 |
为啥JavaScript的sdk里面有jquery, 建议sdk不要使用第三方库 |
这里是包含了 jquery.ajax.js 库,打包后不依赖 jQuery 也可以运行。 |
我在reactnative使用不了,说是有jquery,而reactnative是可以使用ajax的 |
node怎么计算签名给前端用? |
https://github.com/tencentyun/cos-js-sdk-v5/blob/master/server/sts-auth.php
理解起来还是挺费劲的,有没有现成的sdk可以做这个事情,帮助生成签名 就好
The text was updated successfully, but these errors were encountered: