Uploading an image from Android (with Android Asynchronous Http Client) to rails server (with paperclip)

前端 未结 3 922
误落风尘
误落风尘 2020-12-13 07:47

I\'m trying to upload an image file via http post method from android device to rails server. But posting an image is not working. More specifically, the post parameter (inc

3条回答
  •  执笔经年
    2020-12-13 08:16

    There's a description like below, in Android AsyncHttpClient official page (http://loopj.com/android-async-http/)

    "Multipart file uploads with no additional third party libraries"

    and in the section of "Uploading Files with RequestParams", they have a sample code to upload an image

    File myFile = new File("/path/to/file.png");
    RequestParams params = new RequestParams();
    try {
        params.put("profile_picture", myFile);
    } catch(FileNotFoundException e) {}
    

    This is what I did, though didn't work. Does this help answering my question?

提交回复
热议问题