<input id="file-selector" type="file">
<script src="dist/cos-js-sdk-v5.min.js"></script>
<script>
var Bucket = 'test-1250000000';
var Region = 'ap-guangzhou';
// 初始化实例
var cos = new COS({
getAuthorization: function (options, callback) {
// 异步获取签名
$.get('../server/auth.php', {
method: (options.Method || 'get').toLowerCase(),
pathname: '/' + (options.Key || '')
}, function (authorization) {
callback(authorization);
}, 'text');
}
});
// 监听选文件
document.getElementById('file-selector').onchange = function () {
var file = this.files[0];
if (!file) return;
// 分片上传文件
cos.sliceUploadFile({
Bucket: Bucket,
Region: Region,
Key: file.name,
Body: file,
}, function (err, data) {
console.log(err, data);
});
};
</script>
{
method: (options.Method || 'get').toLowerCase(),
pathname: '/' + (options.Key || '')
}
中的参数分别是什么意思?在生成签名时有什么作用? 我使用python sdk获取的签名
config = CosConfig(Secret_id=secret_id, Secret_key=secret_key, Region=region, Token=token)
client = CosS3Client(config)
authorization = client.get_auth(Method='GET', Bucket=bucket1-1255389510
, Key=test.png)
为什么在上边的js sdk老是报 "SignatureDoesNotMatch"的错?
相似问题