S3 Tagging Error - The TagValue you have provided is invalid

Viewed 1757

We are using tagging in S3 for some files, however, if we use an "& " character in the value of the key value pair, I get the following error

"The TagValue you have provided is invalid"

Any ideas on how to get around this to work in S3?

Here is the code we are using with the AWS Sdk

    var documents = await GetDocumentsAsync(clientDoc.ClientId);
    var objectKey = $"{clientDoc.ClientId}/{clientDoc.FileName}";

    var newTagSet = new Tagging
    {
        TagSet = new List<Tag>{
            new Tag { Key = "ClientName", Value = clientDoc.ClientName ?? "" }
        }
    };

    var putObjTagsRequest = new PutObjectTaggingRequest()
    {
        BucketName = _systemConfig.S3BucketName,
        Key = objectKey,
        Tagging = newTagSet
    };

    var response = await s3Client.PutObjectTaggingAsync(putObjTagsRequest);

1 Answers
Related