DWorkS / VolleyPlus

🏐 Volley library : make everything faster . Its an improvements for Volley by Google for Android https://android.googlesource.com/platform/frameworks/volley
https://github.com/DWorkS/VolleyPlus
984 stars 275 forks source link

File/String not uploading to server #67

Open AhmadullahSaikat opened 7 years ago

AhmadullahSaikat commented 7 years ago
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 commented 6 years ago

Did you resolve this?

alex-podolian commented 6 years ago

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

IssueHuntBot commented 6 years ago

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

IssueHuntBot commented 6 years ago

@larrytech7 has started working. Visit this issue on Issuehunt

IssueHuntBot commented 6 years ago

@larrytech7 has stopped working. Visit this issue on Issuehunt

larrytech7 commented 6 years ago

@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 commented 6 years ago

@amitkr936 has started working. Visit this issue on Issuehunt

1hakr commented 6 years ago

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

IssueHuntBot commented 5 years ago

@1hakr has started working. See it on IssueHunt

IssueHuntBot commented 5 years ago

@1hakr has rewarded. See it on IssueHunt