使用打字稿中的AWS开发工具包(请原谅代码,它仍处于开发阶段):
在我的Angular2服务中:
return this.bucket.deleteObject(params).promise();
在我的组件中:
this.uploadService.delete(key).then(/*returns before bucket is consistent, listing its contents still shows the deleted item for a few seconds);
如何让我的UI与S3存储桶的状态保持一致?之后几秒钟我是否需要轮询它并显示某种进度指示器?
答案 0 :(得分:1)
嘿,快看看你是如何获得承诺的。我认为你在服务中不需要.promise()。你试过这样的事吗:
export class TestComponent
{
private key = 'something';
constructor(private uploadService: UploadService)
{
}
ngOnInit()
{
this.uploadService
.delete(this.key)
.then((err, data) =>
{
if (err)
{
console.log(err, err.stack);
}
else
{
console.log(data);
}
})
}
}
export class UploadService
{
delete(params)
{
return this.bucket.deleteObject(params);
}
}