Node.js AWS S3: Delete Tags from Object

Back to Index

Deletes the tags associated with an object. This example deletes the tags for the object named "starfish.jpg" located in the bucket "chilkat100". A response status code = 204 is returned for success.

Documentation: https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETEtagging.html

CURL Command

curl -X DELETE https://chilkat100.s3.amazonaws.com/starfish.jpg?tagging

Node.js Example

var os = require('os');
if (os.platform() == 'win32') {  
    var chilkat = require('chilkat_node6_win32'); 
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('chilkat_node6_arm');
    } else if (os.arch() == 'x86') {
        var chilkat = require('chilkat_node6_linux32');
    } else {
        var chilkat = require('chilkat_node6_linux64');
    }
} else if (os.platform() == 'darwin') {
    var chilkat = require('chilkat_node6_macosx');
}

function chilkatExample() {

    var rest = new chilkat.Rest();
    var success;

    var authAws = new chilkat.AuthAws();
    authAws.AccessKey = "AWS_ACCESS_KEY";
    authAws.SecretKey = "AWS_SECRET_KEY";
    authAws.Region = "us-east-1";
    authAws.ServiceName = "s3";
    rest.SetAuthAws(authAws);

    //  URL: https://chilkat100.s3.amazonaws.com/starfish.jpg?tagging
    var bTls = true;
    var port = 443;
    var bAutoReconnect = true;
    success = rest.Connect("chilkat100.s3.amazonaws.com",port,bTls,bAutoReconnect);
    if (success !== true) {
        console.log("ConnectFailReason: " + rest.ConnectFailReason);
        console.log(rest.LastErrorText);
        return;
    }

    var sbResponseBody = new chilkat.StringBuilder();
    success = rest.FullRequestNoBodySb("DELETE","/starfish.jpg?tagging",sbResponseBody);
    if (success !== true) {
        console.log(rest.LastErrorText);
        return;
    }

    var respStatusCode = rest.ResponseStatusCode;
    if (respStatusCode >= 400) {
        console.log("Response Status Code = " + respStatusCode);
        console.log("Response Header:");
        console.log(rest.ResponseHeader);
        console.log("Response Body:");
        console.log(sbResponseBody.GetAsString());
        return;
    }


}

chilkatExample();