library/src/main/java/com/github/lykmapipo/retrofit/HttpService.java
public static synchronized List<MultipartBody.Part> createFileParts(
            @NonNull Map<String, Object> files
    ) {
        // initialize multipart list
        List<MultipartBody.Part> parts = new ArrayList<MultipartBody.Part>();
        // collect request body parts
        if (!files.isEmpty()) {
            for (String key : files.keySet()) {
                Object value = files.get(key);
                boolean isAllowedPart =
                        !TextUtils.isEmpty(key) && (value instanceof File);
                if (isAllowedPart) {
                    File file = (File) value;
                    MultipartBody.Part part = createFilePart(key, file);
                    parts.add(part);
                }
            }
        }
        // return multipart list
        return parts;
    }
/**
     * Helper method to convert map of files to list of multipart request body.
     *
     * @param files {@link Map}
     * @return {@link okhttp3.MultipartBody.Part}
     * @since 0.6.0
     */
Helper method to convert map of files to list of multipart request body.
Helper method to convert map of files to list of multipart request body .
public static synchronized List<MultipartBody.Part> createFileParts(
            @NonNull Map<String, Object> files
    ) {
        List<MultipartBody.Part> parts = new ArrayList<MultipartBody.Part>();
        if (!files.isEmpty()) {
            for (String key : files.keySet()) {
                Object value = files.get(key);
                boolean isAllowedPart =
                        !TextUtils.isEmpty(key) && (value instanceof File);
                if (isAllowedPart) {
                    File file = (File) value;
                    MultipartBody.Part part = createFilePart(key, file);
                    parts.add(part);
                }
            }
        }
        return parts;
    }
public static synchronized List < MultipartBody . Part > createFileParts ( @ NonNull Map < String , Object > files ) { List < MultipartBody . Part > parts = new ArrayList < MultipartBody . Part > ( ) ; if ( ! files . isEmpty ( ) ) { for ( String key : files . keySet ( ) ) { Object value = files . get ( key ) ; boolean isAllowedPart = ! TextUtils . isEmpty ( key ) && ( value instanceof File ) ; if ( isAllowedPart ) { File file = ( File ) value ; MultipartBody . Part part = createFilePart ( key , file ) ; parts . add ( part ) ; } } } return parts ; }
Helper method to convert map of files to list of multipart request body.
Helper method to convert map of files to list of multipart request body .
// initialize multipart list // collect request body parts // return multipart list