승인을 통해 Amazon S3 버킷에 파일을 업로드하려고합니다. 내 서명 작업을 알고 있습니다. 동일한 URL, 헤더 및 서명을 hurl.it과 함께 사용하면 업로드가 성공적으로 완료됩니다.HTTP 응답 S3에 업로드시 엔티티가 비어 있지는 않지만 실제로 작동합니다.
또한 내 프로그램이 정상적으로 업로드된다는 것을 알고 있습니다. S3 보안을 해제하고 헤더를 제거하면 업로드가 정상적으로 작동합니다.
HttpClient client = new DefaultHttpClient();
url = "http://mybucket.s3.amazonaws.com/test/" + filename;
HttpPut put = new HttpPut(url);
put.setEntity(entity);
put.addHeader("Date", formattedDate);
put.addHeader("Authorization",
"AWS " + c.getString(R.string.AWSAccessKeyId) +
":" + signature);
put.addHeader("Content-Type",contentType);
HttpResponse httpResponse = client.execute(put);
Log.e(TAG, allHeaders(httpResponse));
HttpEntity responseEntity = httpResponse.getEntity();
InputStream content = responseEntity.getContent();
InputStreamReader is = new InputStreamReader(content);
BufferedReader br = new BufferedReader(is,2000);
String read = br.readLine();
Log.e("AUTH", ">>>"+read+"<<<");
String response = "";
while (read != null){
Log.e("AUTH", read);
read = br.readLine();
response += read + "\n";
}
Log.e("Code:", ""+httpResponse.getStatusLine().getStatusCode());
또한 내가 비동기 안드로이드 에뮬레이터에서이 일을 해요 있음을 주목할 필요가있다.
가Date: Thu, 31 May 2012 05:58:08 GMT
Connection: close
Server: AmazonS3
Transfer-Encoding: chunked
응답 상태 코드 400: Bad Request
이다
얻어진 헤더
은 (Log.e(TAG, allHeaders(httpResponse))
을 사용하여 표시).
이상한 점은이 헤더를 얻을 수 있지만 responseEntity.getContent()
의 콘텐츠 스트림이 완전히 비어 있습니다. while 루프를 입력하지 않습니다.
www.google.com
으로 타겟팅 된 HttpGet
으로 전환하려고 시도했지만 완전히 정상적으로 작동했습니다.
청크 인코딩에 문제가 있습니까? 명백한 실수는 없습니까?