diff --git a/pkg/utils/FileReceiver.go b/pkg/utils/FileReceiver.go index 292cd5f..46b299b 100644 --- a/pkg/utils/FileReceiver.go +++ b/pkg/utils/FileReceiver.go @@ -3,7 +3,6 @@ package utils import ( "bufio" "fmt" - "io" "os" ) @@ -14,12 +13,19 @@ func ReceiveFile(fileName string, fileSize int, reader *bufio.Reader) bool { return false } - println(1) defer file.Close() - _, err := io.CopyN(file, reader, int64(fileSize)) - println(2) - if err != nil { - return false + currentSize := 0 + buffer := make([]byte, 1024) + + for currentSize < fileSize { + length, err := reader.Read(buffer) + if err != nil { + return false + } + + currentSize += length + file.WriteAt(buffer, int64(currentSize)) } + return true }