Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with Image upload In Beta 2.0.0beta2 #1323

Closed
jainsanchits opened this issue Nov 25, 2015 · 1 comment
Closed

Issues with Image upload In Beta 2.0.0beta2 #1323

jainsanchits opened this issue Nov 25, 2015 · 1 comment

Comments

@jainsanchits
Copy link

Trying to upload Image File Using retrofit but Couldnt do it so i found Some work around

For retro fit Call
@multipart
@post("END_POINT OF API")
CalluploadFile(@part("xyz(Filename)";filename="image.*(type of file)" ") RequestBody xyz);

when You Call it using in your App
RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"),new FILE("path to your file"));

        Call<APINAME> fileUploadCall = App.getRestClient(context.this).getApiService().uploadfile(requestBody);
        imageUploadCall.enqueue(new Callback<APINAME>() {
            @Override
            public void onResponse(Response<APINAME> response, Retrofit retrofit) {
                if(response.body().getSuccess())
                {
                }

            }

            @Override
            public void onFailure(Throwable t) {
                try {
                    Log.e("Upload","false");
                    throw t;
                } catch (Throwable throwable) {
                    throwable.printStackTrace();
                }
            }
        });
@JakeWharton
Copy link
Collaborator

Dupe #1140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants