doyp9057 2014-06-07 03:54
浏览 49
已采纳

云存储-可以通过API检索对象,但是在尝试访问MediaLink时会出现奇怪的错误

I am using golang on appengine (go version go1.2.1 (appengine-1.9.3) linux/386)

My new app is having trouble when trying to read a cloud storage file's contents. I can get the Object info via google-api-go-client, and the MediaLink gives me a URL like this:

https://www.googleapis.com/storage/v1beta2/b/bucket/o/profile%2Fpath_to_the_file.jpeg?generation=1402107955298000&alt=media

On dev_app_server or appengine, when I try to urlfetch this jpeg, I get "404 Not Found". When I paste the same URL into my browser, I get a 307 redirect, and then a 200 for a new URL that looks likes this:

https://storage.googleapis.com/bucket/profile%2Fpath_to_the_file.jpeg?generation=1402107955298000

I tried a test and just did a urlfetch request for first a www.googleapis.com URL, and then a storage.googleapis.com URL. The first URL gives a 404, but the second URL gives 200 OK. I have nearly identical code working in another app - why am I getting the false 404s in this instance?

Thanks, Tim.

  • 写回答

1条回答 默认 最新

  • dtg7662 2014-06-09 21:58
    关注

    Apparently this is an issue with how golang parses a URL string and translates it to a net/url struct. You can use the URL.Opaque field to work around this behavior. I didn't write this code, but here is an example of how googleapi addresses this same issue in order to preserve the %2F separators in the path.

    http://play.golang.org/p/TkKRROJTfb

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题
  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”