Example #1
0
File: scp.go Project: nrolans/netb
func (h *SCPHandler) FileCopy(r io.Reader) scp.Status {
	// Prepare a new entry
	e := configstore.NewEntry()
	e.Name = h.name
	e.Date = time.Now()

	// Copy the content
	n, err := io.Copy(e, r)
	if err != nil {
		log.Printf("Error copying file to entry: %s", err)
		return *scp.NewStatus(scp.Warning, "Error copying file")
	}
	log.Printf("Copied %d bytes", n)

	err = h.store.Add(*e)
	if err != nil {
		log.Printf("Error writing entry to store: %s", err)
		return *scp.NewStatus(scp.Warning, "Error saving file")
	}

	return *scp.NewStatus(scp.OK, "")
}
Example #2
0
File: scp.go Project: nrolans/netb
func (h *SCPHandler) DirEndRequest() scp.Status {
	return *scp.NewStatus(scp.Warning, "Not implemented")
}
Example #3
0
File: scp.go Project: nrolans/netb
func (h *SCPHandler) DirRequest(mode os.FileMode, size int64, dirname string) scp.Status {
	return *scp.NewStatus(scp.Warning, "Not implemented")
}
Example #4
0
File: scp.go Project: nrolans/netb
func (h SCPHandler) FileRequest(mode os.FileMode, size int64, filename string) scp.Status {
	return *scp.NewStatus(scp.OK, "")
}