【发布时间】:2019-03-07 17:07:12
【问题描述】:
这是我在网上找到的解决方案:[https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-example-photo-album.html]
function addPhoto(albumName) {
var files = document.getElementById('photoupload').files;
if (!files.length) {
return console.log('Please choose a file to upload first.');
}
var file = files[0];
var fileName = file.name;
var albumPhotosKey = encodeURIComponent(albumName) + '//';
var photoKey = albumPhotosKey + fileName;
s3.upload({
Key: photoKey,
Body: file,
ACL: 'public-read'
}, function(err, data) {
if (err) {
return console.log('There was an error uploading your photo: ', err.message);
}
console.log('Successfully uploaded photo.');
viewAlbum(albumName);
});
}
但是,在我当前的环境中,没有所谓的“文档”这个概念。我真的不知道“文档”是如何工作的。我可以在当前环境中包含“文档”吗?或者我可以使用其他东西来获取本地文件[图像]?非常感谢!
s3.上传:https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property
【问题讨论】:
标签: amazon-web-services amazon-s3