Last active
August 29, 2015 14:13
-
-
Save VEINHORN/f04214cb11c2c1749752 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iodevice = file:open("client/" ++ Filename, [read, binary]) | |
send_file_binary(Socket, IoDevice, Offset) -> | |
case file:pread(IoDevice, Offset, 1000) of | |
{ok, Data} -> | |
io:format("~B bytes sent.", [Offset + 1000]), | |
gen_tcp:send(Socket, <<1:32/integer, Data/binary>>), | |
send_file_binary(Socket, IoDevice, Offset + 1000); | |
eof -> | |
io:format("File sent."), | |
gen_tcp:send(Socket, <<2:32/integer>>) % 2 - uploading is done | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment