benim android uygulamasında yerine buNeden json yerine html/text içerik türü alıyorum? Google Cloud Storage içine resmi yüklerseniz
HTTP/1.1 200 OK
X-GUploader-UploadID AEnB2UqEWk0UEztkHlBDHW5x49RYWkkIfPoHCZ_2g0YpZgvXke7blE7VM8FCJOjoAng6x5kySCLcsoccZVNyS9PdG6UU1F9Q1A
Content-Type application/json
Content-Encoding gzip
X-AppEngine-Estimated-CPM-US-Dollars $0.000041
X-AppEngine-Resource-Usage ms=1256 cpu_ms=359
Vary Accept-Encoding
Date Tue, 05 Apr 2016 13:44:20 GMT
Pragma no-cache
Expires Fri, 01 Jan 1990 00:00:00 GMT
Cache-Control no-cache, must-revalidate
Content-Length 307
Server UploadServer
bu
HTTP/1.1 200 OK
X-GUploader-UploadID AEnB2UrQyfCePM_5kYDFy1sJchgXCTkmRH8sU4S8NrWa-KzVoovFtD5iz8CIAUjegqBfBTK8ACiid0XazBRKqpZRvmUE03JNQg
X-AppEngine-Estimated-CPM-US-Dollars $0.000000
X-AppEngine-Resource-Usage ms=130 cpu_ms=38
Date Tue, 05 Apr 2016 14:01:11 GMT
Pragma no-cache
Expires Fri, 01 Jan 1990 00:00:00 GMT
Cache-Control no-cache, must-revalidate
Content-Length 0
Server UploadServer
Content-Type text/html; charset=UTF-8
var, başlık Uygulaması/json eklendi ve ben çok parçalı olarak göndermek için deneyin ikinci içerik türü android uygulamasından görüntü/İşte png
kodudur böylece:
@Override
protected Void doInBackground(File... params) {
File file = params[0];
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
httppost.setHeader("X-Requested-With","XMLHttpRequest");
httppost.setHeader("Accept","application/json");
FileBody filebody = new FileBody(file, ContentType.create("image/jpeg"), file.getName());
MultipartEntityBuilder multipartEntity = MultipartEntityBuilder.create();
multipartEntity.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
multipartEntity.addPart("file", filebody);
httppost.setEntity(multipartEntity.build());
System.out.println("executing request " + httppost.getRequestLine());
try {
HttpResponse response = httpclient.execute(httppost);
Log.i("response", response.getStatusLine().toString());
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
httpclient.getConnectionManager().shutdown();
return null;
}
Neden json yerine html/text içerik türü alıyorum? Sunucu yanıtı 200, ancak herhangi bir JSON alamadım. Lütfen bana yardım et. thx
Yanıt:
HTTP/1.1 200 OK
X-GUploader-UploadID: AEnB2UqF16tZOCnavA58S1qxTXXopXz5ESh3YIU3ksEv9UsQ6Ro4Oyw03i1CVF7M7GpsLi8_p9ua-agn9upJND_mrXCTGMO-nA
X-AppEngine-Estimated-CPM-US-Dollars: $0.000000
X-AppEngine-Resource-Usage: ms=1164 cpu_ms=28
Date: Tue, 05 Apr 2016 14:29:54 GMT
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Cache-Control: no-cache, must-revalidate
Content-Length: 0
Server: UploadServer
Content-Type: text/html; charset=UTF-8
Olmadığını denedim başlığını –
Kabul Content-Type Başlığını ayarlamak gerektiğini düşünüyorum, ama eror gibi, var Bu İçerik türü bu URL için uygun değil. Bence bu çok parçalı ("Content-Type", "multipart/form-data") var. –
Hangi veriler ** sunucudan geri dönüyorsunuz? Yalnızca üstbilgileri gösterdiniz, ancak html geri alırsanız, belki de beklenen JSON yanıtı yerine biraz html hata sayfası alıyorsunuz –