上传与阵列Retrofit 2.0.0-beta2具有相同名称的多个图像 [英] Upload multiple image with same name as array Retrofit 2.0.0-beta2

查看:51
本文介绍了上传与阵列Retrofit 2.0.0-beta2具有相同名称的多个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我在android上使用翻新,并且还在服务器端上使用laravel 5.1进行文件上传,现在我面临的问题是在翻新中,我想在服务器端发送多个具有相同名称的图像并以此捕获它们名称.

Hello guys i am using retrofit with android and also laravel 5.1 for file uploading on the server side now the problem i am facing is that in retrofit i want to send multiple images with same name on the server side and catch them as that name.

使用邮递员的示例输入:

Example input using postman:

如果有人对此有所了解,请发表评论:)

If anyone know anything about this please comment, post :)

推荐答案

如果这对您也有帮助,我将感到高兴和高兴.

I would be happy and delighted if this could help you as well.

服务器API合同:输入类型:多部分数据

Server API contract : Input Type : Multipart-from data

要通过称为图像"的键在正文中发送的数据

Data to be send in body against key called "images"

@POST("feeds")
Call<> createFeeds(@Body RequestBody file);


 MultipartBody.Builder builder = new MultipartBody.Builder();
    builder.setType(MultipartBody.FORM);
    builder.addFormDataPart("content", textContent);

    for(String filePath : imagePathList){
        File file = new File(filePath);
        builder.addFormDataPart("images", file.getName(),
                RequestBody.create(MediaType.parse("image/*"), file));
    }

    MultipartBody requestBody = builder.build();
    Call<SocialCreateFeedResponse> call = mSocialClient.createFeeds( requestBody);

这篇关于上传与阵列Retrofit 2.0.0-beta2具有相同名称的多个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆