goftp/server 使用教程

  1. go get goftp.io/server
package main

import (
	"log"

	"goftp.io/server/core"
	"goftp.io/server/driver/file"
)

func main() {
	Name := "FTP Server"
	rootPath := "./static" //FTP根目录
	Port := 59044          //FTP 端口
	var perm = core.NewSimplePerm("test", "test")

	// Server options without hostname or port
	opt := &core.ServerOpts{
		Name: Name,
		Factory: &file.DriverFactory{
			RootPath: rootPath,
			Perm:     perm,
		},
		Auth: &core.SimpleAuth{
			Name:     "admin", // FTP 账号
			Password: "admin", // FTP 密码
		},
		Port: Port,
	}
	// start ftp server
	s := core.NewServer(opt)
	err := s.ListenAndServe()
	if err != nil {
		log.Fatal("Error starting server:", err)
	}
}

参考地址:

server - A FTP server framework written by Golanggoftp/server 使用教程https://gitea.com/goftp/server

上一篇:WEB应用开发--SpringMVC部分学习(三)--初步实现SpringMVC文件上传功能


下一篇:百问网7天物联网智能家居(第三天)