dqwh26750 2017-07-26 21:08
浏览 38
已采纳

如何列出和复制具有非字母数字字符的s3键?

I have code which lists keys using ListObjectsPages->Contents->Key and copies those keys using CopyObject. This works in general but for some keys it's complaining NoSuchKey: The specified key does not exist. The set of keys it's complaining about include keys with +.

Oddly, if I use the CLI: aws s3 cp on "foo+bar", the copy works. But I can't use the CLI. I need to use the sdk.

I'm using v1.8.11

As Rayfen mentioned, the plus characters could be the result of space replacement.

Update: Everything was hashed out here https://github.com/aws/aws-sdk-go/issues/1438. Rayfen was right about needing to QueryEscape. I'm going to award the only current answer with the bounty since it adds useful information, but not select it as correct.

  • 写回答

2条回答 默认 最新

  • douxin1956 2017-08-02 15:10
    关注

    This details what was happening: https://github.com/aws/aws-sdk-go/issues/1438

    1. The main issue was that CopySource needs to be url-encoded and not the Key field, which was surprising to me. (I was url-encoding both.)
    2. The other issue was that I was using path.Join which strips out trailing \. This is a problem because s3 keys can have trailing \ - which represents a sort of folder.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!