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

File/String not uploading to server #67

Open
AhmadullahSaikat opened this issue Oct 16, 2017 · 10 comments
Open

File/String not uploading to server #67

AhmadullahSaikat opened this issue Oct 16, 2017 · 10 comments

Comments

@AhmadullahSaikat
Copy link

AhmadullahSaikat commented Oct 16, 2017

private void sendCompanyInformationToServer() {

    SimpleMultiPartRequest smr = new SimpleMultiPartRequest(Request.Method.POST, User.ADD_COMPANY,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    Log.d("Response", response);
                    try {
                        JSONObject jObj = new JSONObject(response);
                        String message = jObj.getString("message");

                        Toast.makeText(activity, message, Toast.LENGTH_LONG).show();

                    } catch (JSONException e) {
                        // JSON error
                        e.printStackTrace();
                        Toast.makeText(activity, "Json error: " + e.getMessage(), Toast.LENGTH_LONG).show();
                    }
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    handleError(error);
                }
            }) {
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String, String> headers = new HashMap<>();
            Log.d(LOG_TAG, "authorization token: " + authorization);
            headers.put(Constants.XREQUESTED_HEADER_KEY, Constants.XREQUESTED_HEADER_VALUE);
            headers.put(Constants.AUTHORIZATION_HEADER_KEY, "Bearer " + authorization);
            return headers;
        }

// @OverRide
// protected Map<String, String> getParams() throws AuthFailureError {
// Map<String, String> params = new HashMap<>();
//
// params.put(User.TITLE, etOrganizationTitle.getText().toString());
//
// params.put(User.PHONE, etOrganizationPhone.getText().toString());
//
// params.put(User.ADDRESS, etOrganizationAddress.getText().toString());
//
// params.put(User.LAT, lat);
//
// params.put(User.LNG, lng);
//
// Log.d(LOG_TAG, "Registration Token: " + authorization);
//
// return params;
// }

    };

    smr.addStringParam(User.TITLE, etOrganizationTitle.getText().toString());

    smr.addStringParam(User.PHONE, etOrganizationPhone.getText().toString());

    smr.addStringParam(User.ADDRESS, etOrganizationAddress.getText().toString());

    smr.addStringParam(User.LAT, lat);

    smr.addStringParam(User.LNG, lng);

    smr.addFile(User.IMAGE, ProductActivity.imageFilePath);

    MyApp.getInstance().addToRequestQueue(smr);

}
@creeartelo-desarrollo
Copy link

Did you resolve this?

@alex-podolian
Copy link

Got the same issue. Please fix it, or let us know what we are doing wrong.

@IssueHuntBot
Copy link

@BoostIO funded this issue with $5. Visit this issue on Issuehunt

@IssueHuntBot
Copy link

@larrytech7 has started working. Visit this issue on Issuehunt

@IssueHuntBot
Copy link

@larrytech7 has stopped working. Visit this issue on Issuehunt

@larrytech7
Copy link

@AhmadullahSaikat did you check that your file path is correct? and that your server is checking for the correct name as your file upload parameter?

@IssueHuntBot
Copy link

@amitkr936 has started working. Visit this issue on Issuehunt

@1hakr
Copy link
Member

1hakr commented Oct 19, 2018

@IssueHuntBot
Copy link

@1hakr has started working. See it on IssueHunt

@IssueHuntBot
Copy link

@1hakr has rewarded. See it on IssueHunt

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

6 participants