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条)

报告相同问题?

悬赏问题

  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应