我使用android的google-api-client。我尝试用文本数据和图像文件做多部分POST请求。创建请求的代码片段如下:
InputStream stream = new FileInputStream(fileToSend);
InputStreamContent photoContent = new InputStreamContent("image/jpeg", stream);
MultipartRelatedContent multiContent =
new MultipartRelatedContent(content, photoContent);
HttpRequest request = getRequestFactory().buildPostRequest(googleUrl, multiContent);content是键值文本内容。结果,我得到了错误500。
我哪里做错了?
发布于 2012-11-27 01:01:18
这里有一个关于如何使用google-api-java-client进行媒体上传的指南:
https://code.google.com/p/google-api-java-client/wiki/MediaUpload
也就是说,我也不认为你的代码有任何问题。可能是googleUrl不正确,或者内容的格式不正确。您可能希望尝试添加一个URL查询参数uploadType=multipart,以指定您正在使用multipart作为协议。
https://stackoverflow.com/questions/13494489
复制相似问题