psanford / wormhole-william

End-to-end encrypted file transfer. A magic wormhole CLI and API in Go (golang).
MIT License
1.08k stars 55 forks source link

wormhole.SendFile: Switch from io.ReadSeeker to io.Reader? #27

Closed Jacalz closed 3 years ago

Jacalz commented 3 years ago

Hi there. I am wondering if the need for supplying an io.ReadSeeker possibly could be changed to using a regular io.Reader?

The question comes from work on wormhole-gui where I would like to try and get it to work on iOS and Android. Getting it working would currently result in a lot of platform specific code for getting a seeker working or might even be impossible when working through the limited APIs exposed by Apple.

It looks like there isn't a massive amount of code relying on it (see search results) and hopefully those size calculations could be done in a different maner. Just using ìo.Reader would make things much better for mobile and wouldn't cause any API breakages as any ìo.ReadSeeker already complies with ìo.Reader.

psanford commented 3 years ago

The size of the file is sent to the receiver as part of the initial metadata (its how the receiver is able to show an accurate progress bar). A Seeker is a natural way to determine that information when you are dealing with files on disk.

If your application has a different mechanism for determining the size of the file you could use something like https://godoc.org/go4.org/readerutil#NewFakeSeeker.

Jacalz commented 3 years ago

Thanks for the explanation. I see that now. There are probably more issues to consider for mobile versions, probably keeping it from making sense any time in the near future. Closing...