0

私の GAE インスタンスは、Google データ ストアに保存された画像を提供します。

def serveAvatarByName(request,username):
    entity_list = Entity.gql("WHERE username = :1", username)
    entity = entity_list.get()     

    if entity:
        image_data = entity.image
        response = HttpResponse(image_data)

        response['Content-Type'] = entity.content_type
    else:        
        image_data = open("static/img/anonymous.png", "rb").read()        
        response = HttpResponse(image_data)

        response['Content-Type'] = 'image/png'        

    response['Accept-Ranges'] = 'bytes'
    response['Cache-Control'] = 'max-age=86400'        
    return response    

私のイメージ URI は通常、次のようになります。

http://my-app.appspot.com/serve_avatar/user1.png

私の Android クライアントは、以下のように構成された素晴らしい Sergey Tarasevich の Universal Image Loader を使用してこれらの画像を取得します。

DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
    .cacheInMemory()
    .cacheOnDisc()
    .build();

ImageLoaderConfiguration config = new ImageLoaderConfiguration
    .Builder(getApplicationContext())
    .defaultDisplayImageOptions(defaultOptions).build();

ImageLoader.getInstance().init(config);

そしてそれらを取得します:

String imageUri1 = "http://my-app.appspot.com/serve_avatar/user1.png";
//String imageUri2 = "http://xpda.com/junkmail/junk207/jpgcompressionb1.png";

ImageLoader.getInstance().displayImage(imageUri1, imageView);

最初の画像 (imageUri1) は Google Data Store インスタンスに保存された PNG であり、imageUri1 を指すブラウザーに正しく表示されますが、UIL は失敗し、ログに次のメッセージが表示されます。

03-28 10:41:37.093: D/skia(25780): --- SkImageDecoder::Factory returned null 

onLoadingFailed メソッドを実装して「failReason」を出力すると、「IO_ERROR」が表示されますが、他には何も表示されません。

ユーザーがアバター画像をアップロードしていない場合は、代わりにデフォルトの画像 (anonymous.png) が提供されます。それもうまくいきません。

2 番目のイメージ (imageUri2、png ファイル) にアクセスすると、UIL が正しく機能することに注意してください。

ヘッダーは次のようになります。

imageUri1 - http://my-app.appspot.com/serve_avatar/user1.png :

HTTP request status: 200 (OK)

Date Thu, 28 Mar 2013 18:05:46 GMT
Cache-Control max-age=86400
Server Google Frontend
Accept-Ranges bytes
Content-Length 41686
Vary Cookie
Content-Type image/png

imageUri2 - http://xpda.com/junkmail/junk207/jpgcompressionb1.PNG :

HTTP request status: 200 (OK)

Date Thu, 28 Mar 2013 14:14:58 GMT
ETag "5de35c2e5eeca1:0"
Last-Modified Sat, 08 May 2010 19:36:30 GMT
Server Microsoft-IIS/7.0
X-Powered-By ASP.NET
Content-Type image/png
Cache-Control max-age=86400
Accept-Ranges bytes
Content-Length 535279

何が間違っている可能性がありますか?

4

1 に答える 1

1

UIL は、画像のダウンロードFlushedInputStream に 1.8.2 より前のバージョンを使用します ( http://code.google.com/p/android/issues/detail?id=6066 )。それはあなたの問題の原因になる可能性があります。1.8.2FlushedInputStreamはデフォルトでは使用されていませんが、 で有効にすることができますImageLoader.handleSlowNetwork(true)

1.8.2にアップデートしてみてください。

于 2013-03-30T09:05:57.340 に答える