jeudi 5 mars 2015

How to post image and video with multiple part HttpConnection android?



While posting single file (image or video) working fine, but when posting both files only first file uploading second skipped.


Here is my code:



//initially connection created
if (imagedata != null)
{
bos.write(("Content-Disposition: form-data; name=\"PopstedImages\";
filename=\""+ rev.finalImage.getName() + "\"\r\n").getBytes());
bos.write(("Content-Type: image/png\r\n\r\n").getBytes());
bos.write(imagedata);
bos.write(("\r\n--" + "----------V2ymHFg03ehbqgZCaKO6jy"
+ "--\r\n").getBytes());
}
if (videobyts != null) {
bos.write(("Content-Disposition: form-data; name=\"PopstedVideos\"; filename=\""
+ rev.videoFile.getName() + "\"\r\n").getBytes());
bos.write(("Content-Type: video/3gp \r\n\r\n").getBytes());
bos.write(videobyts);
bos.write(("\r\n--" + "----------V2ymHFg03ehbqgZCaKO6jy"
+ "--\r\n").getBytes());
}



Aucun commentaire:

Enregistrer un commentaire