Suredata
Suredata

Reputation: 21

Deleting S3 objects created with non-printable characters in the Key?

While mucking around with the AWS PHP SDK (v2) I accidently created a bunch of objects appended with "\r\n". I can see these objects in the AWS console, S3 Browser and Cloudberry Explorer. The browsers show the file extension as, for example, JPG%0D%0A. All attempts to remove these objects via these tools fails.

I can list the objects successfully with: $objects = $s3->getIterator('ListObjects', array('Bucket' => $bucket));

Passing the returned objects to

$result = $s3->deleteObject(array(
        'Bucket' => $bucket,
        'Key'    => $object['Key']"
        ));

does not delete them and there doesn't seem to be a meaningful error message.

Does anyone know any other methods (via versionid perhaps) for deleting objects with non-printable characters? Or even a sample of how to print out the $result?

Please be gentle. I'm a PHP n00b. :)

Upvotes: 0

Views: 224

Answers (1)

Suredata
Suredata

Reputation: 21

Although not a direct solution, I ended up setting the lifecycle period on the bucket to one day and this worked. Not very elegant but at least it's resolved.

The question regarding why you can create keys with non-printable characters but can't delete them still remains.

Upvotes: 1

Related Questions