不使用JavaScript在AWS S3存储桶中上传视频文件

时间:2019-08-08 05:19:47

标签: amazon-web-services amazon-s3

我尝试使用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);
                    });
            }

0 个答案:

没有答案