Upload an image using PUT method instead of POST (MultiPartBuilder)
Hi, I need to upload an image using PUT method but ANRequest mMethod property is set to POST in the contructor for MultiPartBuilder parameter;
public ANRequest(MultiPartBuilder builder) { this.mRequestType = RequestType.MULTIPART; this.mMethod = Method.POST; ... }
¿How can I solve this?
Thanks in advance. Antonio
Hi Amit, if I cannot solve this issue I have to move to another networking library as Retrofit.
Thanks
I will check it on weekend.
Hi Amit, did you have time to check my issue on weekend?
Thank you
Hi Amit, I would like to know if it is possible to solve my issue as soon as possible,... If you have to upload a image file related to an idempotent resource you can not use POST but PUT.
POST /v1/deliveries PUT /v1/deliveries/{id}/labelPhoto
Please, let me know...
@adesousabarroso can you provide me the url to test and confirm you?
@amitshekhariitbhu I'm sorry but at this moment I cannot provide you a live endpoint for you to confirm. The backend team has told me that they will implement it soon... I have already finished the v1 of the client...
I don't know if API Tester could help you https://apitester.com/
Thanks a lot
Hi @amitshekhariitbhu, could you provide me a test version of your lib that uses PUT instead of POST?
Thank you
Hi @amitshekhariitbhu, I'd need to know if you can help me with this or not, otherwise I'll have to take an alternative action.
Thank you in advance
Hi @amitshekhariitbhu, thank you anyway.
@adesousabarroso your suggestion was good. Can we make this soon? help us here to build that quickly. Open for PR from your side also.
Hi Amit, this week I'll try/test the PUT method to upload a file (idempotent). Then I'll be back to you to tell you if it works and send you the changes I've made.
Hi Amit, I have resolved an uploada a file using PUT verb (idempotent) but I haven't used multipart as follows:
ANRequest.PutRequestBuilder builder AndroidNetworking.put( URL );
builder.addHeaders("Cache-Control", "no-cache")
.addHeaders("Connection", "keep-alive")
.addFileBody( FILE_TO_UPLOAD )
.setContentType("image/png") // IMPORTANT: image/*
.setTag( TAG )
.setPriority(Priority.IMMEDIATE);
ANRequest request = builder.build();
request.getAsOkHttpResponse(new OkHttpResponseListener() {
@Override
public void onResponse(Response response) {
// Check response.code()
}
@Override
public void onError(ANError error) {
// Error
}
});
Ciao
Hello, this was solved?
I also need to upload an image using PUT multipart. Or how can it be resolved?
need to upload using post method multipart, why addFileBody not have key ?
@amitshekhariitbhu i'm always use put to update user profile avatar.But .addFileBody() does not have key. I dont want to replace your lib to retrofit. thanks
builder.addHeaders("Cache-Control", "no-cache") .addHeaders("Connection", "keep-alive") .addFileBody( FILE_TO_UPLOAD ) .setContentType("image/png") // IMPORTANT: image/* .setTag( TAG ) .setPriority(Priority.IMMEDIATE);
@ltthuc1989 let me check
are you still checking?
someone find the solution, please tell