【问题标题】:Bad request uploading photo to PicasaWeb from GAE从 GAE 将照片上传到 PicasaWeb 的错误请求
【发布时间】:2014-12-25 01:51:55
【问题描述】:

我正在使用 PicasaWeb 上的上传功能在 Google App Engine 上开发一个网络应用程序。 我使用此代码上传照片:

myService = new PicasawebService("my-picasa-web-service");
myService.setConnectTimeout(60000);
myService.setReadTimeout(60000);
myService.setUserCredentials(USERNAME, PASSWORD);
PhotoEntry myPhoto = new PhotoEntry();
myPhoto.setClient("myAdminClient");
MediaStreamSource myMedia = new MediaStreamSource(stream, "image/jpeg");
myPhoto.setMediaSource(myMedia);
PhotoEntry returnedPhoto = myService.insert(new URL(albumFeedUrl), myPhoto);

其中 stream 变量是带有上传文件的 InputStream。

如果我在独立的客户端程序中运行此代码,它就可以工作。 但是当我使用 GAE 最后一行 raise 和 exception 运行它时,我可以在日志中看到这一点:

com.google.gdata.util.InvalidEntryException: OK
<HTML>
<HEAD>
<TITLE>Bad Request</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Bad Request</H1>
<H2>Error 400</H2>
</BODY>
</HTML>

at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:602)
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:564)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:560)
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538)
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:536)
at com.google.gdata.client.media.MediaService.insert(MediaService.java:400)

你能帮我解决这个错误吗?

我怎样才能获得有关此的更多信息?

谢谢 斯特凡诺

【问题讨论】:

  • 不知道这个问题?

标签: google-app-engine sdk gdata picasa


【解决方案1】:

我发现了问题;它与我使用的内容类型无效有关。 在我的例子中,我报告了“image/jpeg”作为“new MediaStreamSource()”方法的参数。在我的原始代码中,我使用了一个变量作为内容类型,但它的设置方式很糟糕,因此我遇到了错误。

【讨论】:

    猜你喜欢
    • 2014-06-27
    • 2012-12-03
    • 1970-01-01
    • 2012-11-11
    • 2013-01-18
    • 2021-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多