Я пытаюсь загрузить изображение base64 из приложения Angular в корзину Amazon S3.Ниже приведен код, который я использую.
uploadAssets(base64File, assetType, fileName, file) {
const AWSService = AWS;
const region = ""
const bucketName = "";
const identityPoolId = "";
const accessKeyId = "";
const secretAccessKey = "";
AWSService.config.update({
region: region,
accessKeyId: accessKeyId,
secretAccessKey: secretAccessKey,
credentials: new AWSService.CognitoIdentityCredentials({
IdentityPoolId: identityPoolId
})
});
const s3 = new AWSService.S3({
apiVersion: '',
});
var objKey = bucketName+ "/" + fileName;
var params = {
Key: objKey,
ContentType: file.type,
Bucket: bucketName,
Body: base64File,
ContentEncoding: 'base64',
ACL: 'public-read'
};
s3.upload(params, function (err, data) {
if (err) {
console.log(err, 'there was an error uploading your file');
} else {
console.log(data);
}
});
}
По какой-то причине я получаю следующую ошибку
TypeError: Cannot read property 'byteLength'из неопределенного
Я что-то здесь упускаю?