public uploadFileToAws(file, folderName, newFileName) {
var aws_cognito_identity_pool_id = environment.pool_id;
var aws_cognito_region = environment.aws_cognito_region;
var aws_project_region = environment.aws_project_region;
AWS.config.region = aws_project_region;
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: aws_cognito_identity_pool_id
}, {
region: aws_cognito_region
});
AWS.config.update({ customUserAgent: 'MobileHub v0.1' });
const s3 = new S3({
apiVersion: '2006-03-01',
params: { Bucket: environment.bucket }
});
s3.upload({
Key: folderName+'/'+newFileName,
Bucket: environment.bucket,
Body: file,
ACL: 'private'
},function (err, data) {
this.fileuploading = false;
if (err) {
console.log(err, 'there was an error uploading your file');
} else {
console.log(data.Key+ ' uploaded successfully');
}
return true;
});
}