Skip to content

Evaporate.prototype.cancel()

Jakub Žitný edited this page Mar 4, 2017 · 2 revisions

var cancellationPromise = evaporate.cancel([file_key])

file_key is the optional file key of the upload that you want to cancel. If file_key is not defined, then all files will be canceled. File key is constructed as bucket + '/' + object_name.

The completion promise rejects after the file upload aborts.

The cancellationPromise is an implementation of Promises/A+. The promise resolves when the upload is completely canceled or rejects if the upload could not be canceled without errors.

Evaporate.create({
    bucket: 'mybucket'
})
    .then(function (evaporate) {
        evaporate.add({
            name: 'myFile',
            file: new File()
        })
        .then(function (awsKey) {
            console.log('Completed', awsKey);
        },
        function (reason) {
            console.log('Did not upload', reason);
        });

        evaporate.cancel('mybucket/myFile')
            .then(function () {
                console.log('Canceled!');
            });
    })