当前位置: 代码迷 >> Android >> 求大神指教Android Studio使用retrofit,post请求文件上传以二进制流的方式
  详细解决方案

求大神指教Android Studio使用retrofit,post请求文件上传以二进制流的方式

热度:58   发布时间:2016-04-28 00:08:00.0
求大神赐教Android Studio使用retrofit,post请求文件上传以二进制流的方式
以下是图片上传方式:
接口写法:
  @Multipart
    @POST("/user/addLicenseInfo")
    void addLicenseInfo(@QueryMap Map<String, Object> options, @Part("file") TypedFile file, Callback<JsonElement> response);
实现写法:
 API api = mRegisterActivity.createAPI();
        Map<String, Object> options = new HashMap<String, Object>();
        options.put("mobile",photoNumber);
        TypedFile typedImage = new TypedFile(getMIMEType(pictureFile), pictureFile);
        api.addLicenseInfo(options,typedImage,new Callback<JsonElement>(){};

请问大神 以二进制流上传 上传参数应该怎么写?
------解决思路----------------------
上传图片:把Bitmap转换为二进制流    用 ByteArrayOutputStream 捕获内存缓冲区的数据,转换成字节数组!!!
------解决思路----------------------
那不有好多参数类型吗,其中就有个TypedByteArray 感觉这个应该就是二进制的了吧,没用过,都是直接传个文件,就和你代码里一样
  相关解决方案