documented here 메서드를 통해 새로운 API를 통해 인기있는 서비스 인 Dailybooth에 사진을 업로드하려고합니다. 여기유효하지 않은 Content-Length가 서버로 전송됩니까?
<html><head><title>411 Length Required</title>...
내가이 데이터를 보내는 데 사용하고 코드입니다 :
// 2: Build request
HttpClient httpclient = new DefaultHttpClient();
SharedPreferences settings = DailyboothShared.getPrefs(DailyboothTakePhoto.this);
String oauth_token = settings.getString("oauth_token", "");
HttpPost httppost = new HttpPost(
"https://api.dailybooth.com/v1/pictures.json?oauth_token=" + oauth_token);
Log.d("upload", "Facebook: " + facebook);
Log.d("upload", "Twitter: " + twitter);
try {
InputStream f = getContentResolver().openInputStream(snap_url);
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
entity.addPart("picture", new InputStreamBody(f, snap_url.getLastPathSegment()));
entity.addPart("blurb", new StringBody(blurb));
entity.addPart("publish_to[facebook]", new StringBody(facebook));
entity.addPart("publish_to[twiter]", new StringBody(twitter));
httppost.setEntity(entity);
HttpResponse response = httpclient.execute(httppost);
Log.d("upload", response.toString());
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode == 200) {
// do something?
} else {
Log.d("upload", "Something went wrong :/");
}
Log.d("upload", EntityUtils.toString(response.getEntity()));
} catch (Exception ex) {
ex.printStackTrace();
}
나는 '무슨 아이디어가있어
문제는 서버와 응답이다 잘못하고있다.
감사합니다. 이러한 제안을 시도해 보겠습니다. 안타깝게도 필자는 안드로이드 시스템이 나를 그렇게 할 수 없어도 쉽게 "File"객체를 얻으려고 노력했다. –
어떻게 파일을 읽을 수 없습니까? java.io.File은 SDK의 일부이므로 안드로이드에서 그렇게 할 수 있다고 확신합니다. 어쩌면 일부 사용권 문제 일 수 있습니다 – CodegistCRest
URL을 "content : // blah/blah/blah"로 반환 한 카메라 및 다른 응용 프로그램에서 파일을 가져 오려고합니다. 어떤 이유로 File이 열리지 않습니다. 그러나 필자는 파일 설명자를 사용하여 길이를 "계산"할 수있게 변경했습니다. 감사 : D –