2

As described in this answer you cannot grab a progress of a multipart/form POST upload in Android using only the Android SDK, because there is an issue with the stream buffering when using HttpURLConnection which will be fixed post Froyo (see http://code.google.com/p/android/issues/detail?id=3164#c6).

Since the Apache HttpClient 3.1 was removed from the SDK quite early and the new HttpClient, which is now part of the SDK, wasn't adopted completely (it misses multipart capabilities) you can add the missing parts (specifically apache-mime4j-0.6.jar and httpmime-4.0.1.jar) to perform a multipart/form-data upload AND grab the progress of the upload (also described in the answer mentioned above).

Now, the reason why I open a new question is, that doing as described leads to an enormous growth of the installed app size (in my case from 170kb to 732kb).

So, the question is: Is there any other way to perform a multipart/form-data upload and grab the upload progress without increasing the app size that much? Are there any other libraries one can use or is there any other alternative way, not mentioned here?

4

2 に答える 2

0

完全に別の方法。これは、アップロードに時間がかかる場合にのみ問題になる可能性があります。これは、一定の遅延があり、進行状況を1秒あたり最大1倍より頻繁に更新できないためです。

とにかく、これが私の考えです。サーバー側でアップロードの進行状況を追跡できます(たとえば、PHPとAPCを使用)。

Androidでは、HTTPを介してアップロードステータスを頻繁にポーリングし、UIを更新する別のデバイスを起動できます。

このソリューションにはいくつかの欠点があります。これが私が今考えることができることです:

  • 実装が複雑(個別のスレッド、追加のHTTP接続、..)
  • また、サーバー側を制御し、そこで変更を加える必要があります。
  • アップロード中に追加のインターネットトラフィックを作成すると、アップロードが遅くなり、より多くのユーザーがメガバイトを解放する可能性があります。
于 2010-07-14T13:53:53.640 に答える
0

Apache HttpEntity インターフェイスは、概念的には非常に単純です。これは、自身を出力ストリームに書き込むことができ、独自の MIME タイプを認識できる単なるオブジェクトです。マルチパート形式の MIME タイプも非常に単純です。したがって、重要な外部依存関係を持たず、アプリケーションを大幅に膨張させない代替 MultiPartEntity 実装を作成するのは非常に簡単に思えます。

于 2012-03-24T18:37:21.693 に答える