Fuel: [ASK] example file upload & post data with fuel

Created on 15 Jan 2019  路  7Comments  路  Source: kittinunf/fuel

when i only define what keys and values for post data & path to file for file upload

question

All 7 comments

@codenoid, what do you mean? There are some examples in issues. See https://github.com/kittinunf/fuel/issues/479 and https://github.com/kittinunf/fuel/issues/529.

Additionally, check out upload in README.md, and the UploadRequestTests.

@CoolMind is there any example of HashMap<String, String>() var usage for form data with file upload ?

        var client = AsyncHttpClient();
        var params = RequestParams();
        params.put("file", File("/storage/emulated/0/Telegram/Telegram Images/852237039_126976.jpg"));
        params.put("id", "21")
        client.setBasicAuth("username","password");
        client.post(this, "http://5.5.5.68:2018/api/file-upload", params, object: JsonHttpResponseHandler(){
            override fun onSuccess(statusCode: Int, headers: Array<Header>, response: JSONObject) {
                super.onStart()
            }
        });

superb easy

@codenoid, :)
It is AsyncHttpClient, not Fuel. :) Of course, it works, but I am not sure it will work with coroutines or RxJava.

yes sir @CoolMind , from the example, it's easier to work with AsyncHttpClient

@codenoid, ah, understood. Probably it's easier, also you can try Retrofit. I was not right, AsyncHttpClient is compatible with RxJava.
For HashMap probably https://github.com/kittinunf/fuel/issues/56 will help.
Good luck!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jsyeo picture jsyeo  路  5Comments

milk-machine picture milk-machine  路  6Comments

t-ae picture t-ae  路  5Comments

NikkyAI picture NikkyAI  路  3Comments

Querschlag picture Querschlag  路  5Comments