【问题标题】:Send multiple images using 2d Array in android to post data to server using retrofit在 android 中使用 2d Array 发送多个图像,以使用改造将数据发布到服务器
【发布时间】:2019-06-17 01:53:37
【问题描述】:

我必须在 android 中使用 2d 数组上传图库图片。我需要为此目的使用哈希图,但我很困惑如何做到这一点,任何人都可以为此目的提出任何解决方案或示例代码。

【问题讨论】:

    标签: java android multidimensional-array retrofit retrofit2


    【解决方案1】:

    你可以像这样创建你的哈希映射

    HashMap<String, String> images=new HashMap<String, String>();
    meMap.put("image name","image path");
    

    您可以创建这样的键值对,也可以根据您的要求进行更改,但请注意,每个键的键值都应该是唯一的,即图像名称每次都应该不同,因为如果再次插入相同的值,则其值将被覆盖.

    【讨论】:

    • 我可以使用随机数来避免覆盖吗? @Kartika Vij
    • 是的,你使用随机数或时间戳
    • 你能给我看一个示例代码吗,因为我被困在里面了这是我的要求@Kartika Viij .... profile_gallery[0]['base64_string'] string base64_string profile_gallery[0][' name'] string name profile_gallery[0]['type'] string type profile_gallery[2]['base64_string'] string base64_string profile_gallery[2]['name'] string name profile_gallery[2]['type'] string type profile_gallery [3]['base64_string'] 字符串 base64_string profile_gallery[4]['name'] 字符串名称 profile_gallery[3]['type'] 字符串类型
    • 我更喜欢多部分发送图像而不是 base 64 RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), modApplication.itemFileList.get(0)); item_image1 = MultipartBody.Part.createFormData("item_image1", modApplication.itemFileList.get(0).getName(), requestFile);
    猜你喜欢
    • 2018-06-17
    • 2017-06-05
    • 1970-01-01
    • 1970-01-01
    • 2020-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多