Exemple #1
0
func download(file string) {
	if containsFile(file) {
		message := helper.CreateMessage(nil, "Download", file)
		connection := getConnection("localhost", "8000")
		helper.EncodeMessage(*message, connection)
		mess := helper.DecodeMessage(connection)
		if mess.FileName == "" {
			fmt.Println("NO file found")
		} else {
			file := fmt.Sprintf("./%s/%s", "clientFiles", mess.FileName)
			helper.WriteFile(file, mess.Content)
		}

		connection.Close()
	}
}
Exemple #2
0
func upload(message helper.Message, c net.Conn) {
	name := fmt.Sprintf("./%s/%s", "serverFiles", message.FileName)
	helper.WriteFile(name, message.Content)
}