Android photo upload function - MIME

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Android photo upload function - MIME

Postby cock0810 » Fri Oct 25, 2013 7:52 am

Hi,
I’m working on modifying a photo upload program but facing a problem. During packet grabbing, it will not show up “Media Type” and “Data” (Data should be separated to 3, not 1 only). I’ve tried to adjust program codes for many times but still could not get the expecting result. It would be appreciated if anyone who can point out where the problem is. Thank you!!

Code: Select all
/***
* The following parameters are used to upload.
*/
if (param != null && param.size() > 0) {
    Iterator<String> it = param.keySet().iterator();
        while (it.hasNext()) {
        sb = null;
        sb = new StringBuffer();
        String key = it.next();
        String value = param.get(key);
        sb.append(PREFIX).append(BOUNDARY).append(LINE_END);
        sb.append("Content-Disposition: form-data; name=\"").append(key).append("\"").append(        LINE_END).append(LINE_END);
        sb.append(value).append(LINE_END);
        params = sb.toString();
        Log.i(TAG, key+"="+params+"##");
        dos.write(params.getBytes());
    }
}
     
sb = null;
params = null;
sb = new StringBuffer();

sb.append(PREFIX).append(BOUNDARY).append(LINE_END);
sb.append("Content-Disposition: form-data; name=\"" + fileKey + "\"; filename=\"" + file.getName() + "\"" + LINE_END);
sb.append("Content-Type: application/octet-stream" + LINE_END+LINE_END);
sb.append(LINE_END);
     
params = sb.toString();
//sb = null;

sb.append(PREFIX).append(BOUNDARY).append(LINE_END);
sb.append("Content-Disposition: form-data; name=\"seq\""+ LINE_END+LINE_END);
sb.append(LINE_END);
params = sb.toString();
//sb = null;
//dos.write(params.getBytes());
     
sb.append(PREFIX).append(BOUNDARY).append(LINE_END);
sb.append("Content-Disposition: form-data; name=\"lang\""+ LINE_END+LINE_END);
sb.append(LINE_END);
params = sb.toString();
//sb = null;
//dos.write(params.getBytes());
     
sb.append(PREFIX).append(BOUNDARY).append(LINE_END);
sb.append("Content-Disposition: form-data; name=\"tId\""+ LINE_END+LINE_END);
sb.append(LINE_END);
params = sb.toString();
//sb = null;

Log.i(TAG, file.getName()+"=" + params+"##");
dos.write(params.getBytes());
cock0810
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Oct 25, 2013 7:24 am

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 5 guests