Search in sources :

Example 1 with PostRequest

use of com.lzy.okgo.request.PostRequest in project okhttp-OkGo by jeasonlzy.

the class UploadManager method addTask.

/** 添加一个上传任务,默认使用post请求 */
@Deprecated
public <T> void addTask(String url, File resource, String key, UploadListener<T> listener) {
    PostRequest request = OkGo.post(url).params(key, resource);
    addTask(url, request, listener);
}
Also used : PostRequest(com.lzy.okgo.request.PostRequest)

Example 2 with PostRequest

use of com.lzy.okgo.request.PostRequest in project okhttp-OkGo by jeasonlzy.

the class UploadActivity method upload.

@OnClick(R.id.upload)
public void upload(View view) {
    if (images != null) {
        for (int i = 0; i < images.size(); i++) {
            MyUploadListener listener = new MyUploadListener();
            listener.setUserTag(gridView.getChildAt(i));
            PostRequest postRequest = //
            OkGo.post(Urls.URL_FORM_UPLOAD).headers("headerKey1", //
            "headerValue1").headers("headerKey2", //
            "headerValue2").params("paramKey1", //
            "paramValue1").params("paramKey2", //
            "paramValue2").params("fileKey" + i, new File(images.get(i).path));
            uploadManager.addTask(images.get(i).path, postRequest, listener);
        }
    }
}
Also used : PostRequest(com.lzy.okgo.request.PostRequest) File(java.io.File) OnClick(butterknife.OnClick)

Example 3 with PostRequest

use of com.lzy.okgo.request.PostRequest in project BaseProject by feer921.

the class BaseOkgoApi method postWithParams.

/**
 * 带有请求参数/值,键值对的post请求
 * @param wholeApiUrl 完整的api url地址
 * @param callback 回调
 * @param keysInParams 参数键
 * @param keysValues 参数值
 */
public static void postWithParams(String wholeApiUrl, AbsCallback callback, String[] keysInParams, String... keysValues) {
    PostRequest postRequest = postRequest(wholeApiUrl);
    buildCommonRequestParams(postRequest, keysInParams, keysValues);
    excute(postRequest, callback);
}
Also used : PostRequest(com.lzy.okgo.request.PostRequest)

Example 4 with PostRequest

use of com.lzy.okgo.request.PostRequest in project BaseProject by feer921.

the class BaseOkgoApi method justPostRequestWithParams.

/**
 * 仅仅为构建携带请求参数的Post请求,excute()自行完成(可同步/异步)
 * @param wholeApiUrl 完整APi 请求地址
 * @param appendKeys keys
 * @param keyValues values
 * @return PostRequest
 */
public static PostRequest justPostRequestWithParams(String wholeApiUrl, String[] appendKeys, String... keyValues) {
    PostRequest postRequest = OkGo.post(wholeApiUrl);
    buildCommonRequestParams(postRequest, appendKeys, keyValues);
    return postRequest;
}
Also used : PostRequest(com.lzy.okgo.request.PostRequest)

Aggregations

PostRequest (com.lzy.okgo.request.PostRequest)4 OnClick (butterknife.OnClick)1 File (java.io.File)1