由于各种历史原因,我在 s3 上看到了一系列文件,这些文件的标题中的时间表示为“HH:MM:SS”(以及其他字符)。文件名以及不包含这些字符的其他文件是通过 SQS 发送给我的。
我可以读取不包含“:”字符的文件,但对于那些包含“:”字符的文件却没有成功。我尝试了各种 UUEncode/Decode 过程,但一切都给了我这个错误:
Caught an AmazonServiceException, which means your request made it to Amazon S3,
but was rejected with an error response for some reason.
Error Message: The specified key does not exist.
(Service: Amazon S3; Status Code: 404; Error Code: NoSuchKey;
我想知道是否有某种方法可以对 key 进行编码,以便可以访问文件。
最佳答案
文档表明冒号字符属于可能需要特殊处理的字符(请参阅 docs ):
The following characters in a key name may require additional code handling and will likely need to be URL encoded or referenced as HEX.
根据this list ,冒号字符的十六进制值为 %3A
。
换句话说,当您指定 key 时,将“:”字符替换为“%3A”,它应该可以正常工作。
关于java - s3 : streaming file(s) with embedded ':' in title,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38206788/