2022-03-08 12:01:51 +01:00
|
|
|
package utils
|
2022-03-08 20:37:49 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|