如何在浏览器中使用javascript sdk在AWS s3存储桶中上传多部分文件 [英] How to upload multipart files in aws s3 bucket using javascript sdk in browser

查看:362
本文介绍了如何在浏览器中使用javascript sdk在AWS s3存储桶中上传多部分文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用该功能

var bucket = new AWS.S3({params: {Bucket: 'mybucket'}});
var params = {Key: file.name, ContentType: file.type};
bucket.createMultipartUpload(params, function (err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else     console.log(data);           // successful response
});

它获得成功的响应包括上载的id,但是我无法在s3存储桶中找到该文件.那么,还有其他方法可以从浏览器的javascript sdk中分段上传文件吗??我正在使用AWS Cognito进行身份验证. 预先感谢.

Its getting successful response consists of uploadedid but i cant find the file in the s3 bucket. So is there any other ways for multipart upload files from javascript sdk from browser??. I am using aws cognito for authentication. Thanks in advance.

推荐答案

您使用的密钥是文件名.因此,如果上传正确,文件应该出现在mybucket/file.name.此外,您可以在控制台上记录内容,看看是否有任何问题.

The key you are using is the filename. So the file if uploaded properly should be present at mybucket/file.name.Moreover you can log things on console to see if anything is going wrong.

这篇关于如何在浏览器中使用javascript sdk在AWS s3存储桶中上传多部分文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆