question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uploading large images using retrofit 2

See original GitHub issue

Iam using Retrofit 2.3.0 to upload images to a .Net framework server, the uploading of images i working fine … ubt when i try to upload >5MB images it gives me an error when i logged the request it doesn’t read the full file and gives EOF exception … and i do have to compress the image with about 50% quality which is not very good iam using MultiPart to upload and this is my code snippet

    RequestBody requestFile =
                    RequestBody.create(MediaType.parse("image/jpeg"), file);
            MultipartBody.Part body =
                    MultipartBody.Part.createFormData("image", file.getName(), requestFile);

// add another part within the multipart request
            RequestBody fullName =
                    RequestBody.create(
                            MediaType.parse("multipart/form-data"), image.getDescription());

and this is the okHttp log

                 --------- beginning of main
10-30 14:25:45.330 11236-11402/com.project.peoject D/OkHttp: �Dwm�1l�n�D�RXZX�1[)$M��l�`��7Q���n�ӟ̊e�L،����=�k���*a�~�g��=�U�ɨ@<�x��/���>� ���R��@��z;c�?��Zʖ7��ۮ�0�*r����#ך�����3�J��F{���v�	��Kǩ�$||
                                                               
                                                               read: unexpected EOF!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
ritunagpalcommented, Mar 26, 2018

@JakeWharton @Bhoomika06 I am facing same issue if i am sending files for more than 3 mb. Code is working fine for files size under 2 mb. Please help me out.

4reactions
Bhoomika06commented, Dec 27, 2017

Hello Folk, I am facing the same problem while uploading video file (Size: around 6 MB) along with Image file. When I tried to sent only Video, Still got Same Error. If You can suggest anything to me; Please Give Suggestions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uploading large images using Retrofit 2 - Stack Overflow
I have solved this issue by compressing the image file using the Compressor library https://github.com/zetbaitsu/Compressor.
Read more >
Retrofit 2 — How to Upload Files to Server - Future Studio
This tutorial will show you how to upload a file to a backend server using the second major release of Retrofit, namely Retrofit...
Read more >
Upload file in Android Java with retrofit 2 | by Vo Thanh Tung
Upload file in Android Java with retrofit 2 · 1. Add retrofit 2 to gradle file (app level). · 2. Create Retrofit Instance...
Read more >
Upload Files To Server Using Retrofit 2 In Android - C# Corner
Retrofit · Open Android Studio and Select Create a new project. · Name the project as your wish and select your activity template....
Read more >
Let's Develop an Android App to Upload Files and Images
The users and creators must have the added functionality to upload images directly by accessing the phone storage. In this tutorial, we are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found