我是用的官方文档的代码测试的,使用multipartUpload方法。
代码如下:
document.getElementById('file').addEventListener('change', function (e) {
 var file = e.target.files[0];
 var storeAs = 'upload-file';
 console.log(file.name + ' => ' + storeAs);
 var client = new OSS.Wrapper({
  accessKeyId: '****************',
  accessKeySecret: '************',
  stsToken: '****************',
  endpoint: '************',
  bucket: '*************'
 });
 client.multipartUpload(storeAs, file).then(function (result) {
 console.log(result);
 }).catch(function (err) {
 console.log(err);
 });
});
client的各参数确认是在后台获取之后放到JS对象里面的,我只上传了一个文件,然后控制台报错:
POST <--requestUrl--> 400 (Bad Request)
index.html:30 Error: One or more of the specified parts could not be found or the specified entity tag might not have matched the part's entity tag.
    at o.<anonymous> (file:///C:/Users/Administrator/Desktop/TestAliyun/aliyun-oss-sdk-4.4.4.min.js:4:16188)
    at i (file:///C:/Users/Administrator/Desktop/TestAliyun/aliyun-oss-sdk-4.4.4.min.js:6:23661)
    at u._invoke (file:///C:/Users/Administrator/Desktop/TestAliyun/aliyun-oss-sdk-4.4.4.min.js:6:25098)
    at u.e.(anonymous function) [as next] (file:///C:/Users/Administrator/Desktop/TestAliyun/aliyun-oss-sdk-4.4.4.min.js:6:23840)
    at i (file:///C:/Users/Administrator/Desktop/TestAliyun/aliyun-oss-sdk-4.4.4.min.js:6:23661)
    at u._invoke (file:///C:/Users/Administrator/Desktop/TestAliyun/aliyun-oss-sdk-4.4.4.min.js:6:24720)
    at u.e.(anonymous function) [as next] (file:///C:/Users/Administrator/Desktop/TestAliyun/aliyun-oss-sdk-4.4.4.min.js:6:23840)
    at a (file:///C:/Users/Administrator/Desktop/TestAliyun/aliyun-oss-sdk-4.4.4.min.js:9:25589)
    at <anonymous>
然后响应返回:
    <Error>
         <Code>InvalidPart</Code>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
-------------------------
-------------------------
-------------------------
-------------------------
-------------------------