读取CSV文件,转换map数据。文件上传scp

This commit is contained in:
TsMask
2023-09-11 21:03:53 +08:00
parent 614e792670
commit f9596f6363
3 changed files with 97 additions and 0 deletions

View File

@@ -6,6 +6,8 @@ import (
"io"
"net/http"
"net/url"
"os"
"path/filepath"
"ems.agt/lib/core/vo"
"github.com/gorilla/mux"
@@ -67,6 +69,36 @@ func FileAttachment(w http.ResponseWriter, r *http.Request, filepath, filename s
http.ServeFile(w, r, filepath)
}
// 将文件上传保存到指定目录
// file, handler, err := r.FormFile("file")
// SaveUploadedFile uploads the form file to specific dst.
func SaveUploadedFile(r *http.Request, dst string) error {
// 解析请求中的文件
_, handler, err := r.FormFile("file")
if err != nil {
return err
}
src, err := handler.Open()
if err != nil {
return err
}
defer src.Close()
if err = os.MkdirAll(filepath.Dir(dst), 0750); err != nil {
return err
}
out, err := os.Create(dst)
if err != nil {
return err
}
defer out.Close()
_, err = io.Copy(out, src)
return err
}
/// ==== 登录用户信息, 通过中间件后预置入
// 定义自定义类型作为键