更新可配置爬虫:添加上传GridFS

This commit is contained in:
marvzhang
2019-11-25 13:36:14 +08:00
parent b8592b89ce
commit 178e46dd93
3 changed files with 60 additions and 2 deletions

View File

@@ -254,6 +254,25 @@ func _Compress(file *os.File, prefix string, zw *zip.Writer) error {
return nil
}
func GetFilesFromDir(dirPath string) ([]*os.File, error) {
var res []*os.File
if err := filepath.Walk(dirPath, func(path string, info os.FileInfo, err error) error {
if !IsDir(path) {
f, err2 := os.Open(path)
if err2 != nil {
return err
}
res = append(res, f)
}
return nil
}); err != nil {
log.Error(err.Error())
debug.PrintStack()
return res, err
}
return res, nil
}
// File copies a single file from src to dst
func CopyFile(src, dst string) error {
var err error