开发者

How to download Base64 data partly from web server and decode partly from encoded data?

My Base64 encoded data is very Large and comes dynamic not fixed fetch from web server for every transaction. So i need to fetch encode data partly and decode partly from base64 encoded data. Base64 encoded data is tiff image data.

For develop this fu开发者_高级运维nctionality i create one function in which all base64 encoded data download partly from web server and store in txt file.when all data are stored in txt file. then i start decode data partly and create tiff image file.

base64 encoded data not stored partly (means not download partly) and come only once trip from web server then partly base64 decode working fine and tiff image download successfully...

But when store base64 encode data partly(download from web server partly) and comes more times trip or loop for downloading data and storing and partly base64 decode then tiff image not download... not working


I am not sure, whether I understand your problem, but I will try:

  • Whenever you decode base64 image sent in 1 go it works, but when you receive parts of it in few instalments, decode fails. If that is the case, you have to be clever about gluing your received parts together. Please remember that each character of Base64 encoding represents 7 bits of information not 8. You cannot simply append received characters into one big file, array or string. Does your server use base64 padding when sending chunks?

  • Please remember that Android does not support TIFF natively. Try using PNG or JPEG.

  • It would make much more sense, if the server sent it as binary data and you opened the stream on the connection and decoded the image from that stream on the fly using BitmapFactory class

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜