local-s3
local-s3 copied to clipboard
change in behavior observed between local s3 and amazon s3 related to taggingcount.
Scenario : I added objects using putObject() with tagging as null, and then when I try by using getObject() which returns S3Object, when I try getTaggingCount() I receive null response from Amazon S3. But the same when I tried in local-s3(version 1.15/latest), I see that getTaggingCount() returns 0.
Sample Code :
AmazonS3 s3Client = AmazonS3ClientBuilder.standard() .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("hostname", "region")) .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("my_access_key", "my_secret_key"))) .build();
String bucketName = "testbucketname";
//s3Client.createBucket(bucketName);
List<Tag> tags = new ArrayList<>();
// tags.add(new Tag("Key1", "Value1")); // tags.add(new Tag("Key2", "Value2"));
ObjectTagging objectTagging = new ObjectTagging(tags);
String fileName = "......./testJson.json";
File putTagFile = new File(fileName);
PutObjectRequest putObjectRequest = new PutObjectRequest("testbucketname", "your", putTagFile)
.withTagging(objectTagging);
s3Client.putObject(putObjectRequest);
S3Object objectStream = s3Client.getObject("testbucketname", "your");
System.out.println("taggingCount : "+objectStream.getTaggingCount());
GetObjectTaggingRequest getTaggingRequest = new GetObjectTaggingRequest("testbucketname", "your");
GetObjectTaggingResult taggingResult = s3Client.getObjectTagging(getTaggingRequest);
System.out.println("versionId : "+taggingResult.getVersionId());
When fixing this bug, need to check the object tag count in 2 scenarios:
- Scenario 1: Create an object without tags.
- Scenario 2: Create an object with tags. Then delete all tags of the object.