小编san*_*avi的帖子

如何在使用改造发送到服务器之前压缩捕获的图像文件大小

我正在使用 Retrofit retrofit:2.1.0' 将文件图像上传到服务器

如果我使用前置摄像头拍摄图像成功上传但如果拍摄后置摄像头它没有上传我认为因为大文件大小的图像没有上传是否有任何选项可以在发送到服务器进行改造之前压缩文件大小?

文件发送编码

  map.put("complaint_category", RequestBody.create(parse("text"), caty_id_str.getBytes()));

    // Map is used to multipart the file using okhttp3.RequestBody
    File file = new File(Config.uriImage);
    // Parsing any Media type file
    RequestBody requestBody = RequestBody.create(parse("*/*"), file);
    MultipartBody.Part fileToUpload = MultipartBody.Part.createFormData("photo", file.getName(), requestBody);
    RequestBody filename = RequestBody.create(parse("text/plain"), file.getName());

    Call<PostComplaint> call3 = apiInterface.postComplaint(fileToUpload, filename, map);
    call3.enqueue(new Callback<PostComplaint>() {
        @Override
        public void onResponse(Call<PostComplaint> call, Response<PostComplaint> response) {

            progressDoalog.dismiss();

            PostComplaint respon = response.body();

            PostComplaint.Response respo = respon.getResponse();

            String result = respo.getResult();
            String data = respo.getData(); …
Run Code Online (Sandbox Code Playgroud)

android image-compression retrofit2

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

image-compression ×1

retrofit2 ×1