Before i will start i see a lot of questions about this but nothing works for me maybe someone can explained or display it to me how can compress bitmap to MultiPart entity and than send it to the server correct using Retrofit
Bitmap to MultiPartEntity using retrofit
5.1k Views Asked by moshe kobi At
2
There are 2 best solutions below
0
Monster Brain
On
For those who come here for solution, here's mine.
First create a temporary file based on that bitmap
Convert Bitmap to file in Android (Stack Overflow)
Then get that file and add as multipart file
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file);
MultipartBody.Part fileBody = MultipartBody.Part.createFormData("imageFile", file.getName(), requestFile);
Related Questions in ANDROID
- Delay in loading Html Page(WebView) from assets folder in real android device
- MPAndroidChart method setWordWrapEnabled() not found
- Designing a 'new post' android activity
- Android :EditText inside ListView always update first item in the listview
- Android: Transferring Data via ContentIntent
- Wrong xml being inflated android
- AsyncTask Class
- Unable to receive extras in Android Intent
- Website zoomed out on Android default browser
- Square FloatingActionButton with Android Design Library
- Google Maps API Re-size
- Push toolbar content below statusbar
- Android FragmentPagerAdapter Circular listview
- Layout not shifting up when keyboard is open
- auDIO_OUTPUT_FLAG_FAST denied by client can't connect to localhost
Related Questions in BITMAP
- How can I extract the bounds of a bitmap in a canvas from the values in the transformation matrix?
- Displaying bitmap image on Android (OpenCV)
- Change color of bitmap by color Transform Matrix not working
- TImagelist for large images
- crop bitmap in screen size from custom width
- Bitmap too large to be uploaded into a texture (3000x1547, max=2048x2048)
- Converting Bitmap to ByteArray and back to Bitmap not working
- Trying to make a random pixel in a bitmap a new color, but it is giving an error why
- Resizing images failing on start, setContentView & bitmap factory[android]
- Pass image URL/URI from Activity A to open as Image in Activity B Android
- Draw cirble bitmap in onDraw() ImageView without creating another bitmap
- android Bitmap Subsampling of Image
- fast converting Bitmap to BitmapSource wpf
- How to save image to sdcard when using Fresco?
- How to check each bit in 16 bit address in C
Related Questions in RETROFIT2
- Error with retrofit 2 : java.lang.NoSuchMethodError: com.google.gson.Gson.newJsonReader, after updating gradle
- JSON object parsing using retrofit2.0
- Send a Post with url parameter with Retrofit 2
- Android Upload Multiple Files In A Single Request
- Android : Post to server success but okhttp return ECONNRESET (Connection reset by peer)
- How do I inject an abstraction using an IOC container like Dagger 2
- OkHttp - Cannot add custom header
- post parameter that passed in as @Field does not being added into RequestBody in Retrofit2?
- How to handle JSONP response through Retrofit and GsonConverter?
- How do you add constant Body fields in retroift POST request?
- Unable to upload video using Retrofit, possible fix?
- How to create POJO for duplicate property name in JSON for Android Retrofit library
- Dagger 2 multiple Retrofit instances built with different URLs for hitting different APIs using constructor injection
- Retrofit 2: No virtual method newJsonReader(Ljava/io/Reader;) NoSuchMethodException
- Retrofit2 issue with posting array
Related Questions in MULTIPARTENTITY
- While uploading image to server (error while uploading)
- how to parse xml data from HTTPResponse in android
- Sending a file with HttpPost?
- MultipartEntity post array
- How to couple MultipartEntity and List array to send in httppost in android
- how to send data to server through MultipartEntity
- Sending multiple images to the server from android
- Bitmap to MultiPartEntity using retrofit
- Attachment upload to Jira Service Desk using REST
- Support for HTTP multipart response in Netty?
- Android: upload file with filling out POST body together
- Can I write multiple byte arrays to an HttpClient without client-side buffering?
- How to POST a request in any of rest clients for mime type as "multipart/related"
- How to get files from PHP server?
- How to compress a video to maximum level android
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
First you create a ResponseBody of the file and parse it as a MultipartBody.Part:
This filePart can then be passed to your Retrofit Service, which should look like this: