OKHTTPUploadImage icon indicating copy to clipboard operation
OKHTTPUploadImage copied to clipboard

How do we upload a nested json with files??

Open PembaTamang opened this issue 6 years ago • 0 comments

My Json looks like this:

[{"key":"value","key1":"value1"},
[{"innerkey":"innervalue","filename":"name"},{"innerkey":"innervalue","filename":"name"}]]

the Inner JSONArray is the one with the files how is it supposed to fit in the code??

I Have used a HashMap for another non nested JSONObject like this:

 MultipartBody.Builder multipart = new MultipartBody.Builder();
        for (Map.Entry<String, String> entry : data.entrySet()) {
            String key = entry.getKey();
            String value = entry.getValue();
            if(!key.equals("filePath")){
                multipart.addFormDataPart(key, value);

            }else{

                String filename = "";
                String type = MyUtility.getMimeType(key);
                filename = key.substring(key.lastIndexOf("/") + 1);
                multipart.addFormDataPart("fileName", filename, RequestBody.create(MediaType.parse(type), new File(key)));
            }
        }

please help

PembaTamang avatar Feb 05 '19 04:02 PembaTamang