gpt4 book ai didi

reactjs - 类型错误 : Cannot read property 'byteLength' of undefined - AWS S3 Upload

转载 作者:行者123 更新时间:2023-12-04 11:23:14 24 4
gpt4 key购买 nike

我正在处理来自 React 客户端的 aws s3 照片上传,但遇到以下错误:TypeError: Cannot read property 'byteLength' of undefined我假设上传对象存在缺陷,但我相信 s3/cognito 配置可能有问题,因为我在调用 s3.listObjects 时收到相同的错误。 .我正在关注这些文档 - https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-example-photo-album-full.html
有什么想法吗?

uploadPhoto() {
const files = document.getElementById("photoUpload").files;
if (!files.length) {
return alert("Please choose a file to upload first.");
}
const file = files[0];
const fileName = file.name;
const albumPhotosKey = encodeURIComponent('screenshots') + "/";

const photoKey = albumPhotosKey + fileName;

// Use S3 ManagedUpload class as it supports multipart uploads

const upload = new AWS.S3.ManagedUpload({
params: {
Bucket: <Bucket Name>,
Key: fileName,
Body: file
}
});

const promise = upload.promise();

promise.then(
function(data) {
alert("Successfully uploaded photo.");
console.log('UPLOAD: ', data)
},
function(err) {
console.log('ERROR: ', err)
// return alert("There was an error uploading your photo: ", err.message);
}
);
}

最佳答案

我在 React Native 应用程序中遇到了这个错误。我可以通过关闭我的开发工具网络检查器来修复它。

关于reactjs - 类型错误 : Cannot read property 'byteLength' of undefined - AWS S3 Upload,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65815639/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com