waku-org / examples.waku.org

Examples on how to use the js-waku library
http://examples.waku.org/
Apache License 2.0
29 stars 9 forks source link

Do you have an example of transferring pictures? #175

Open yopoing opened 1 year ago

yopoing commented 1 year ago

Does waku support sending pictures and files? I think status.im supports image sending, but I can't find an example. How can I implement this?thanks!

weboko commented 1 year ago

Currently we do not have any examples of transferring files. If your image can be encoded into base64 - you can send it as text but if you are looking for a way to send files in general, then theoretically, it is possible to do so by sending binary data.

@fryorcraken maybe you can advise here?

TODO for myself:

yopoing commented 1 year ago

Currently we do not have any examples of transferring files. If your image can be encoded into base64 - you can send it as text but if you are looking for a way to send files in general, then theoretically, it is possible to do so by sending binary data.

@fryorcraken maybe you can advise here?

TODO for myself:

  • [ ] provide an example with sending files capability;

Thanks a lot. I now use base64 to transfer pictures and files, but the character data of base64 has tripled in size. I am trying some string compression algorithms to make the data smaller.

yopoing commented 1 year ago

Currently we do not have any examples of transferring files. If your image can be encoded into base64 - you can send it as text but if you are looking for a way to send files in general, then theoretically, it is possible to do so by sending binary data.

@fryorcraken maybe you can advise here?

TODO for myself:

  • [ ] provide an example with sending files capability;

Is status.im sending pictures in a centralized way? Or is it also transmitted through base64?

danisharora099 commented 1 year ago

Is status.im sending pictures in a centralized way? Or is it also transmitted through base64?

According to https://github.com/status-im/status-web/blob/5b48b614e86c7917631fab43e1a7b9b3b8865854/packages/status-js/src/client/chat.ts#L492, looks like it's encoded in bytes.

@felicio can confirm.

fryorcraken commented 1 year ago

Please note that relay support a maximum size of 1MB.

To send pictures, I first recommend to keep the size under 1MB. If over, then alternative solutions such as IPFS may be preferable (for example, upload on IPFS and transmit the IPFS hash over Waku).

felicio commented 1 year ago

Is status.im sending pictures in a centralized way? Or is it also transmitted through base64?

According to https://github.com/status-im/status-web/blob/5b48b614e86c7917631fab43e1a7b9b3b8865854/packages/status-js/src/client/chat.ts#L492, looks like it's encoded in bytes.

@felicio can confirm.

Base64 bytes encoded and sent over Waku. I also like [@]fryorcraken's proposal.

fryorcraken commented 1 year ago

More brainstorming is needed.

Keen to have this as a bounty.

3 ways to exchanging file:

  1. Upload on IPFS
  2. Encoded to base64, include in Waku Message
  3. Binary chunks
  4. Compressed low-quality being shared over Waku and high-definition over IPFS

(2) and (3) can be problematic as there is a 1MB size limit and Waku Store is a bottleneck for Waku.


Would be keen to have a PoC that uses noise for e2ee and enables image sending. However, current noise device pairing is more a device pairing UX.

Would be good to have noise XK1 done so that bob could share a "public key" and Alice can use that to initialize handshake and chat, then feature to send image.

Note that we want to do XK1 for https://github.com/waku-org/js-waku/issues/1181

fryorcraken commented 9 months ago

FYI we are considering a bounty https://github.com/waku-org/bounties/issues/18