I am working on replacing the communication API with retrofit2Only
Communicating plain text parameters works well
Blocked in placing and uploading image.
The result keeps failing, but I don't know where the problem is.
Below is the Android source code, and I would appreciate it if you could answer where it is wrong or missing<
==================================================================
..... ApiInterface.class
@Multipart
@POST(BaseVariable.URL_INSERT)
Call<Results> postInsert(@PartMap Map<String, RequestBody> params);
..... ..... MainActivity.class
Map<String, RequestBody> map = new HashMap<>();
map.put("user_id", toRequestBody("user_id")); // User ID value (string)
File = newFile(thumbnailFile.getPath()); // The address of the image file is verified
RequestBody fileBody = RequestBody.create(MediaType.parse("image/*"), file);
map.put("url_upload", fileBody);
Call<Results> repos = MainApplication.getApiInterface().postInsert(map);
repos.enqueue(new Callback<Results>() {
@Override
public void onResponse(Response<Results> response) {
.....
Looking at the GitHub issue below, retrofit 1.Unlike x, @Part("file\"; filename=\"photo.It seems that an annotation should be added in a format such as png") RequestBody file
.
If you use the map like the code you posted, I think you can handle it as follows. (The filename photo.png is optional.)
map.put("url_upload\"; filename=\"photo.png\"", fileBody);
Or you can use MultipartBody.Part, but MultipartBody.Part is required to hand over the file name when it is created in the first place.
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
581 PHP ssh2_scp_send fails to send files as intended
915 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
611 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.