コード例 #1
0
ファイル: scp.go プロジェクト: 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, "")
}
コード例 #2
0
ファイル: scp.go プロジェクト: nrolans/netb
func (h *SCPHandler) DirEndRequest() scp.Status {
	return *scp.NewStatus(scp.Warning, "Not implemented")
}
コード例 #3
0
ファイル: scp.go プロジェクト: nrolans/netb
func (h *SCPHandler) DirRequest(mode os.FileMode, size int64, dirname string) scp.Status {
	return *scp.NewStatus(scp.Warning, "Not implemented")
}
コード例 #4
0
ファイル: scp.go プロジェクト: nrolans/netb
func (h SCPHandler) FileRequest(mode os.FileMode, size int64, filename string) scp.Status {
	return *scp.NewStatus(scp.OK, "")
}