我想知道最近是否有任何关于从外部应用程序上传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上的日志,似乎没有触发负责/上传的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;
}
答案 0 :(得分: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)修复了问题。