StoreBackEnd/pkg/utils/FileReceiver.go

26 lines
455 B
Go
Raw Normal View History

package utils
import (
"bufio"
"fmt"
"io"
"os"
)
// ReceiveFile Permet de récupérer un fichier sur un reader
func ReceiveFile(fileName string, fileSize int, reader *bufio.Reader) bool {
file, fileErr := os.Create(fmt.Sprintf("/home/benjamin/sbe/%s", fileName))
if fileErr != nil {
return false
}
println(1)
defer file.Close()
_, err := io.CopyN(file, reader, int64(fileSize))
println(2)
if err != nil {
return false
}
return true
}