amazon-web-services - 不使用 javascript 在 AWS S3 存储桶中上传视频文件
问题描述
我尝试使用 javascript AWS SDK 在 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);
});
}
解决方案
推荐阅读
- java - What the reason of such output "println" order? How to initialize object in this code?
- kubernetes - 使用 DEX (LDAP) 进行身份验证时组为空
- git - git checkout -B 没有重置或替代方案?
- python - How to use one bot for different websites
- jquery - Trying to get the first 5 characters of input 1, and first character of input 2
- git - 如何修复:git push 失败:文件“app.config”和推送的文件“App.config”不同,以防万一
- python - How to loop through dictionary to get both frequency of words and symbols?
- python - 将图像存储在对象中
- python - 如何在 Flask Marshmallow 模式中加载查询字符串参数
- java - 如何从一个文本文件中读取整数,将它们从最小到最大排序,然后将它们写入另一个文本文件