我尝试使用JavaScript AWS开发工具包在AWS S3存储桶中上传视频文件,但无法上传
JS代码:
function uploadFile(dir) {
var files = document.getElementById('photoupload').files;
if (!files.length) {
return alert('Please choose a file to
upload first.');
}
var file = files[0];
var fileName = file.name;
var albumPhotosKey = encodeURIComponent(dir) + '//';
var photoKey = albumPhotosKey + fileName;
s3.putObject({
Key: photoKey,
Body: file,
ContentType: file.type,
ACL: 'public-read'
}, function (err, data) {
if (err) {
return alert('There was an error
uploading your file: ', err.message);
}
alert('Successfully uploaded file.');
// viewAlbum(albumName);
});
}