0

我想知道最近在从外部应用程序将 blob 上传到 appengine 方面是否有任何变化?仅在 3 个月前还可以正常工作的东西现在在做 http 帖子上传 blob 时挂起。

之前运行良好的代码(见下文)包括从 AppEngine 获取拉取队列(使用 REST API),对接收到的任务执行一些操作,然后将结果作为 Blob 上传回 AppEngine。将 blob 上传到的 url 由 appengine 使用 blobstoreService.createUploadUrl("/upload"); 创建。

形式为:

      http://myapp.appspot.com/_ah/upload/AMmfu6aAHnkuS4ngyRJDn7urFFZeBxb_-3P-r7RY9udMvRjLWkEZNJMgUX1DFczNVi-NhIxcFat2AEPXs2IRJ0AOmznSMgcrCKmL7mGAmS7nqtr-UyYFkglD88BwCfzIui9M2yez7DSQ/ALBNUaYAAAAAUGRlEwpeGEc5ozp8Z8sDO33qgCi2AiIE/

我查看了 AppEngine 上的日志,似乎负责 /upload 的 servlet 没有被触发。

老实说,我在这个阶段没有想法,任何帮助将不胜感激!:-)

干杯,

基利安

 public boolean uploadAsBlob(String dataToWrite, String uploadURL) {

 try {

      BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(tempFileLocation));

      bufferedWriter.write(dataToWrite);

      bufferedWriter.newLine();

      bufferedWriter.close();

      MultipartEntity entity = new MultipartEntity();

      entity.addPart(blobFileName, new FileBody(new File(tempFileLocation)));

      HttpPost method = new HttpPost(uploadURL);

      method.setEntity(entity);

      final HttpParams httpParams = new BasicHttpParams();

      HttpConnectionParams.setConnectionTimeout(httpParams, 10000);

      DefaultHttpClient httpclient = new DefaultHttpClient(httpParams);


      //It hangs at the following line!

      HttpResponse response = httpclient.execute(method);

      if (response.getStatusLine().getStatusCode() == 200) {

           logger.info("Uploaded blob to url: " + uploadURL);

           return true;

      } else {

           logger.warning("Couldn't upload blob to url: " + uploadURL);

      }



      } catch (Exception e) {

      logger.warning("Exception " + e.getMessage() + " occured while uploading blob to url:" + uploadURL);

      logger.warning("Couldn't upload blob to url: " + uploadURL);

      }

      return false;

      }
4

1 回答 1

0

我发现 GAE 最近开始在调用 blobstoreService.createUploadUrl() 时保留任何 GET 参数。就我而言:

http://www.myapp.com/BG?_=1354631578951

使用此(意外)参数,创建的 URL 为:

http://www.myapp.com/_ah/upload/?_=1354631578951/AMmfu6YgVPoJzWXdbf70k6J0zdjEeRnnRJ2PYCb3Jgdwk3SqmKEnFyKgy_17CKwiqbC2HyO-FlPVX-C53W0LjHSywaq7YmLegD97uU-GrpWRdBdWbfKf0Dk/ALBNUaYAAAAAUL4L8iDS5E99f3Wky2p59wWpCD84AqoP/

请注意,“_”参数仍然存在。删除参数(或者可能从 GET 移动到 POST)解决了这个问题。

于 2012-12-04T14:40:08.173 回答