IBM COS SDK for JavaScript V2 - v1.0.0
    Preparing search index...

    This operation is not supported for directory buckets.

    Sets the supplied tag-set to an object that already exists in a bucket. A tag is a key-value pair. For more information, see Object Tagging.

    You can associate tags with an object by sending a PUT request against the tagging subresource that is associated with the object. You can retrieve tags by sending a GET request. For more information, see GetObjectTagging.

    For tagging-related restrictions related to characters and encodings, see Tag Restrictions. Note that Amazon S3 limits the maximum number of tags to 10 tags per object.

    To use this operation, you must have permission to perform the s3:PutObjectTagging action. By default, the bucket owner has this permission and can grant this permission to others.

    To put tags of any other version, use the versionId query parameter. You also need permission for the s3:PutObjectVersionTagging action.

    PutObjectTagging has the following special errors. For more Amazon S3 errors see, Error Responses.

    • InvalidTag - The tag provided was not a valid tag. This error can occur if the tag did not pass input validation. For more information, see Object Tagging.

    • MalformedXML - The XML provided does not match the schema.

    • OperationAborted - A conflicting conditional action is currently in progress against this resource. Please try again.

    • InternalError - The service was unable to apply the provided tag to the object.

    The following operations are related to PutObjectTagging:

    You must URL encode any signed header values that contain spaces. For example, if your header value is my file.txt, containing two spaces after my, you must URL encode this value to my%20%20file.txt.

    Use a bare-bones client and the command you need to make an API call.

    import { S3Client, PutObjectTaggingCommand } from "ibm-cos-sdk-v2"; // ES Modules import
    // const { S3Client, PutObjectTaggingCommand } = require("ibm-cos-sdk-v2"); // CommonJS import
    // import type { S3ClientConfig } from "ibm-cos-sdk-v2";
    const config = {}; // type is S3ClientConfig
    const client = new S3Client(config);
    const input = { // PutObjectTaggingRequest
    RetentionLegalHoldId: "STRING_VALUE",
    Bucket: "STRING_VALUE", // required
    Key: "STRING_VALUE", // required
    VersionId: "STRING_VALUE",
    ContentMD5: "STRING_VALUE",
    ChecksumAlgorithm: "CRC32" || "CRC32C" || "SHA1" || "SHA256" || "CRC64NVME",
    Tagging: { // Tagging
    TagSet: [ // TagSet // required
    { // Tag
    Key: "STRING_VALUE", // required
    Value: "STRING_VALUE", // required
    },
    ],
    },
    ExpectedBucketOwner: "STRING_VALUE",
    RequestPayer: "requester",
    };
    const command = new PutObjectTaggingCommand(input);
    const response = await client.send(command);
    // { // PutObjectTaggingOutput
    // VersionId: "STRING_VALUE",
    // };

    PutObjectTaggingCommandInput

    S3ServiceException

    Base exception class for all service exceptions from S3 service.

    // The following example adds tags to an existing object.
    const input = {
    Bucket: "examplebucket",
    Key: "HappyFace.jpg",
    Tagging: {
    TagSet: [
    {
    Key: "Key3",
    Value: "Value3"
    },
    {
    Key: "Key4",
    Value: "Value4"
    }
    ]
    }
    };
    const command = new PutObjectTaggingCommand(input);
    const response = await client.send(command);
    /* response is
    {
    VersionId: "null"
    }
    */

    Hierarchy

    Index

    Constructors

    Constructors

    • Returns PutObjectTaggingCommand

    • Parameters

      Returns PutObjectTaggingCommand