开发者

P2P Ajax image transfer

开发者 https://www.devze.com 2023-03-25 19:42 出处:网络
I am using Ajax to retrieve images from a remote server. First I try this directly using the URL of the remote server - the returned image is a string(since that\'s how Ajax communicates). I use the J

I am using Ajax to retrieve images from a remote server. First I try this directly using the URL of the remote server - the returned image is a string(since that's how Ajax communicates). I use the Javascript fromCharCode and CharCodeAt to convert the data back to binary and then the window.btoa() to display it开发者_Python百科. This works. Then I want to transfer this image through an overlay network (P2P). I intercept the Ajax request, transfer it to the server through the P2P network and then retrieve the response in []byte array. But now I need to know to what type of string I should convert the byte array before I feed it back to the calling Ajax client. If I use Base64 or simply convert the byte array to string it does not display the image correctly.

Anyone has tried working with something like this before?

I will appreciate any feedback very much. Thanks


Javascript doesn't have different kinds of strings.

The desired character set will be the same one the web page is encoded in, ideally UTF-8.

Have you compared the response sent by the P2P server to the response sent by the original server? Is there some kind of wrapper that's missing, or perhaps an important MIMEtype difference?

0

精彩评论

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