以下结果有效:
upload(): void {
AWS.config.update({
region: AWSREGION,
credentials: new AWS.CognitoIdentityCredentials(
{
IdentityPoolId: AWSIDENTITYPOOLID,
IdentityId: obj.IdentityId,
Logins: {
'cognito-identity.amazonaws.com': obj.Token
}
}
)
});
this.awsToken = obj.Token;
// set bucket
this.bucket = new AWS.S3({params: {Bucket: 'myBucket'}});
// Set request
this.request = this.bucket.putObject(params);
// Upload to S3
this.request.send((err, data) => {
if (err) {
console.log('AWS Error', err);
} else {
// Success
console.log('Success');
}
});
}
我的取消按钮
cancel(): void {
this.request.abort();
}