使用改造下载图像文件

编程入门 行业动态 更新时间:2024-10-07 06:51:24
本文介绍了使用改造下载图像文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在我的Andr​​oid项目使用改造1.6.0,

I use Retrofit 1.6.0 on my Android project,

请求URL:

example/image/thumbs/filename/sample.png

我的界面是这样的:

public interface ImageService { @GET("/image/thumbs/filename/{filename}") @Streaming void getThumbs( @Path("filename") String filename, Callback<Response> callback ); }

HTTP请求是成功的,但也有一些错误发生

HTTP request was success, but there some error occur

D/Retrofit(27613): ---> HTTP GET example/image/thumbs/filename/sample.png D/Retrofit(27613): ---> END HTTP (no body) D/Retrofit(27613): <--- HTTP 200 example/image/thumbs/filename/sample.png (451ms) D/Retrofit(27613): : HTTP/1.1 200 OK D/Retrofit(27613): Connection: Keep-Alive D/Retrofit(27613): Content-Disposition: inline; filename="sample.png" D/Retrofit(27613): Content-Type: image/png; charset=binary D/Retrofit(27613): Date: Wed, 11 Jun 2014 06:02:31 GMT D/Retrofit(27613): Keep-Alive: timeout=5, max=100 D/Retrofit(27613): OkHttp-Received-Millis: 1402466577134 D/Retrofit(27613): OkHttp-Response-Source: NETWORK 200 D/Retrofit(27613): OkHttp-Sent-Millis: 1402466577027 D/Retrofit(27613): Server: Apache/2.2.22 (Ubuntu) D/Retrofit(27613): Transfer-Encoding: chunked D/Retrofit(27613): X-Powered-By: PHP/5.4.28-1+deb.sury~precise+1 D/Retrofit(27613): ---- ERROR example/image/thumbs/filename/sample.png D/Retrofit(27613): java.io.UnsupportedEncodingException: binary D/Retrofit(27613): at java.nio.charset.Charset.forNameUEE(Charset.java:322) D/Retrofit(27613): at java.lang.String.<init>(String.java:228) D/Retrofit(27613): at retrofit.RestAdapter.logAndReplaceResponse(RestAdapter.java:478) D/Retrofit(27613): at retrofit.RestAdapter.access$500(RestAdapter.java:109) D/Retrofit(27613): at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:333) D/Retrofit(27613): at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220) D/Retrofit(27613): at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278) D/Retrofit(27613): at retrofit.CallbackRunnable.run(CallbackRunnable.java:42) D/Retrofit(27613): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) D/Retrofit(27613): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) D/Retrofit(27613): at retrofit.Platform$Android$2$1.run(Platform.java:142) D/Retrofit(27613): at java.lang.Thread.run(Thread.java:841) D/Retrofit(27613): Caused by: java.nio.charset.UnsupportedCharsetException: binary D/Retrofit(27613): at java.nio.charset.Charset.forName(Charset.java:309) D/Retrofit(27613): at java.nio.charset.Charset.forNameUEE(Charset.java:320) D/Retrofit(27613): ... 11 more D/Retrofit(27613): ---- END ERROR

我该如何解决这个问题?

How do I solve this problem?

推荐答案

这个问题是在响应Content-Type头包括一个虚假的字符集:

The issue is the content-type header on the response includes a bogus charset:

Content-Type: image/png; charset=binary

改造认为这并推断响应是文本,它可以记录。你应该将问题报告给服务器的管理员。

Retrofit sees this and infers that the response is text that it can log. You should report the problem to the server's administrator.

如果您在GitHub上改造的问题跟踪报告问题,我们或许可以从这个问题中恢复,而不是崩溃。

If you report the issue to Retrofit's issue tracker on GitHub, we can probably recover from this problem rather than crashing.

更多推荐

使用改造下载图像文件

本文发布于:2023-10-10 18:11:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1479347.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!