我正在尝试将图像以及从表单收集的一些JSON数据上传到服务器。
服务器具有身份验证。
METHOD: post
HEADERS:
Authorization Basic d2Vic2VydmljZTpyM05hdTE3Rw==
Content-Type multipart/form-data;boundary=xxxxxxxx
BODY:
--xxxxxxxx
Content-Disposition: form-data; name="jsonFile"
Content-Type: application/json
{"model":"Premium","deviceLongitude":4.79337638,"pseudo":"nickname","deviceLatitude":45.7671507,"year":"2005","email":"[email protected]","deviceLocale":"fr_FR","title":"my picture"}
--xxxxxxxx
Content-Disposition: form-data; name="imgName"
Content-Type: image/jpeg
//Image data array
/9j/4AAQSkZJRgABAQAAAQABAAD/4QBYRXhpZgAATU0AKgAAAAgAAgESAAMAAAAB
AAEAAIdpAAQAAAABAAAAJgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAB4KAD
AAQAAAABAAACgAAAAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEB
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
AQEBAQEBAQH/wAARCAKAAeADAREAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAA
AAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF
--xxxxxxxx
最佳答案
最后一行应该是--xxxxxxxx--
,而不是--xxxxxxxx
。
关于android - 将图片与Android中的JSON数据一起上传到Multipart中的服务器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5416038/