我正在尝试通过PUT
方法将文件上传到我自己的存储桶,但无法正常工作:
function upload(url, data) {
var pd = new XMLHttpRequest();
pd['open']('PUT', "http://storage.googleapis.com/" + url, true);
pd['setRequestHeader']('Content-type', 'text/html');
pd['setRequestHeader']('x-goog-acl', 'public-read');
pd['setRequestHeader']('Authorization', 'Bearer *********F0aIu4NbTd6A');
pd['setRequestHeader']('Content-length', data['length']);
pd['setRequestHeader']('Connection', 'close');
pd['send'](data);
}
upload('bucked/index.html','<b>hello</b>');