メタデータのない写真をPicasaウェブアルバムにアップロードするときにエラーが発生しました(403 Forbiddenを返します)。(メモ:OAuth2.0を使用しています。「userId」はGmailアドレス[数値ID]ではありません)機会がわかりません。誰でもテクニカルサポートに感謝します
public String setdData(Context context, String filePath, String userId, String albumId, String accessToken) {
// new ImageUploader(context, filePath, filePath).run();
String url = "https://picasaweb.google.com/data/feed/api/user/" + userId + "/albumid/"
+ albumId;
HttpClient httpClient = new DefaultHttpClient();
File file = new File(filePath);
HttpPost httpPost = new HttpPost(url);
httpPost.setHeader("GData-Version", "2");
// httpPost.addHeader("MIME-version", "1.0");
httpPost.setHeader("Content-type", "image/jpeg");
httpPost.setHeader("Slug", "plz-to-love-realcat.jpg");
// httpPost.addHeader("Content-Length", String.valueOf(file.length()));
httpPost.setHeader("Authorization", "GoogleLogin auth=" + accessToken);
// httpPost.setHeader("Authorization", "OAuth " + accessToken);
InputStreamEntity reqEntity;
org.apache.http.HttpResponse response;
try {
reqEntity = new InputStreamEntity(new FileInputStream(file), file.length());
String CONTENTTYPE_BINARY = "binary/octet-stream";
reqEntity.setContentType(CONTENTTYPE_BINARY);
reqEntity.setChunked(true);
httpPost.setEntity(reqEntity);
response = httpClient.execute(httpPost);
Log.d("Picasa Upload", "STATUS CODE : " + response.getStatusLine().getStatusCode());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}