简体   繁体   中英

How can I tell, in the browser, that my s3 operation has completed and the state of my bucket is consistent?

Using the AWS SDK from typescript (please excuse the code, it's still in development):

In my Angular2 service:

return this.bucket.deleteObject(params).promise();

In my component:

this.uploadService.delete(key).then(/*returns before bucket is consistent, listing its contents still shows the deleted item for a few seconds);

How can I keep my UI consistent with the state of the S3 bucket? Do I have to poll it for a few seconds afterward and show some kind of progress indicator?

Hey had a quick look at how you are accessing the promise. I dont think you need .promise() in the service. Have you tried it like this:

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);
    }

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM