Git Product home page Git Product logo

retrofitclient's Issues

关于下载进度的问题

DownLoadManager里面的"下载进度"不是写文件的进度吗,writeResponseBodyToDisk方法的ResponseBody是下载完成后才有的

导入项目报错

你的demo下载下来,报错:Error:Connection timed out: connect. If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle.,请问怎么解决?

demo有问题

java.lang.ClassCastException: okhttp3.ResponseBody$1 cannot be cast to com.tamic.retrofitclient.net.BaseResponse
一直提示这个 无法转换

大文件无法下载

大神 我现在下载大文件,点击下载一直没有反应,小文件是没有问题的,怎么解决

你好,关于图文上传的方法

你好,
我APP内用的是这个方法上传图片+参数
@post()
Flowable upload(@url String url, @Body RequestBody Body);

调用方式如下:
public Flowable upload(String url, Map<String, String> params, Map<String, String> files) {
final MultipartBody.Builder builder = new MultipartBody.Builder().setType(MultipartBody.FORM);
Flowable.fromIterable(params.entrySet()).subscribe(
new Consumer<Map.Entry<String, String>>() {
@OverRide
public void accept(Map.Entry<String, String> entry) throws Exception {
builder.addFormDataPart(entry.getKey(), entry.getValue());
}
});
if (files != null && files.size() > 0) {
//多张图片
Flowable.fromIterable(files.entrySet()).subscribe(
new Consumer<Map.Entry<String, String>>() {
@OverRide
public void accept(Map.Entry<String, String> entry) throws Exception {
File file = new File(entry.getValue());//filePath 图片地址
RequestBody imageBody = RequestBody.create(MediaType.parse("image/*"), file);
builder.addFormDataPart(entry.getKey(), file.getName(),imageBody);
}
});
}
LogUtils.d(API_TAG, "upload url = " + url +
" :: params = " + params.toString() +
" :: files = " + files.toString());
return bindLifeCycle(getIBaseService().upload(url, builder.build()));
}

结果发现服务器那边都收不到我发送过去的图片,不知道什么原因,请问你们一般是如何上传图片+参数的呢?

你好

478104175 加下QQ 为什么这么多年还没更新

我之前下载过一次,那个没有问题,这个报错了,下面是报错信息。

08-22 19:06:40.743 6767-6767/com.tamic.retrofitclient E/Tamic: java.io.IOException: unexpected end of stream on okhttp3.Address@ecf82dd4
08-22 19:06:40.743 6767-6767/com.tamic.retrofitclient E/Lyk: java.io.IOException: unexpected end of stream on okhttp3.Address@ecf82dd4

08-22 19:06:58.273 6767-6767/com.tamic.retrofitclient E/Tamic: java.net.SocketTimeoutException
08-22 19:06:58.273 6767-6767/com.tamic.retrofitclient E/Lyk: java.net.SocketTimeoutException

08-22 19:07:06.173 6767-6767/com.tamic.retrofitclient E/Tamic: com.google.gson.internal.LinkedTreeMap cannot be cast to com.tamic.retrofitclient.IpResult
08-22 19:07:06.173 6767-6767/com.tamic.retrofitclient E/Lyk: java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to com.tamic.retrofitclient.IpResult

08-22 19:09:22.093 11669-11669/com.tamic.retrofitclient E/Tamic: java.lang.ClassCastException: okhttp3.ResponseBody$1 cannot be cast to com.tamic.retrofitclient.net.BaseResponse
08-22 19:09:22.093 11669-11669/com.tamic.retrofitclient E/Lyk: java.lang.ClassCastException: okhttp3.ResponseBody$1 cannot be cast to com.tamic.retrofitclient.net.BaseResponse

每一个请求都报错

点第一请求个出现:com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 19 path $.data

点第二个请求出现:java.lang.RuntimeException

出问题了

看到你的文章 http://www.jianshu.com/p/1a5f14b63f47 我才用了interceptror的方法来持久化cookie。
代码如下

public class SaveCookiesInterceptor implements Interceptor {
    private static final String TAG = "SaveCookiesInterceptor";

    @Override
    public Response intercept(Chain chain) throws IOException {
        Response originalResponse = chain.proceed(chain.request());

        if (!originalResponse.headers("Set-Cookie").isEmpty()) {
            HashSet<String> cookies = new HashSet<>();
            cookies.addAll(originalResponse.headers("Set-Cookie"));
            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(App.context);
            if (sharedPreferences.getStringSet("cookies", null) == null) {
                Log.d(TAG, "intercept: " + cookies.toString());
                sharedPreferences.edit()
                        .putStringSet("cookies", cookies)
                        .apply();
            }
        }

        return originalResponse;
    }
}

如你所见我加了一行 if (sharedPreferences.getStringSet("cookies", null) == null) {的判断。
这是因为遇到一个问题:模拟登陆成功,但是获取个人资料页返回的是登录页面的数据。然后我经过尝试加了那行代码就好了。请问这是为什么?有可能是什么原因?谢谢

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.