首页 > 解决方案 > 不使用 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);
                    });
            }

标签: amazon-web-servicesamazon-s3

解决方案


推荐阅读