VolleyPlus icon indicating copy to clipboard operation
VolleyPlus copied to clipboard

File/String not uploading to server

Open AhmadullahSaikat opened this issue 8 years ago • 10 comments
trafficstars

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);

}

AhmadullahSaikat avatar Oct 16 '17 14:10 AhmadullahSaikat

Did you resolve this?

creeartelo-desarrollo avatar Jul 03 '18 15:07 creeartelo-desarrollo

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

alex-podolian avatar Jul 19 '18 12:07 alex-podolian

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

IssueHuntBot avatar Aug 06 '18 09:08 IssueHuntBot

@larrytech7 has started working. Visit this issue on Issuehunt

IssueHuntBot avatar Aug 08 '18 17:08 IssueHuntBot

@larrytech7 has stopped working. Visit this issue on Issuehunt

IssueHuntBot avatar Aug 08 '18 17:08 IssueHuntBot

@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?

larrytech7 avatar Aug 08 '18 19:08 larrytech7

@amitkr936 has started working. Visit this issue on Issuehunt

IssueHuntBot avatar Oct 01 '18 15:10 IssueHuntBot

@AhmadullahSaikat https://github.com/DWorkS/VolleyPlus/wiki/Multipart-Request follow this example

1hakr avatar Oct 19 '18 04:10 1hakr

@1hakr has started working. See it on IssueHunt

IssueHuntBot avatar Oct 31 '18 13:10 IssueHuntBot

@1hakr has rewarded. See it on IssueHunt

IssueHuntBot avatar Oct 31 '18 13:10 IssueHuntBot