Feat: archive download and sign temp url

This commit is contained in:
HFO4
2019-12-13 11:41:22 +08:00
parent 012281c41f
commit cf9416ef88
7 changed files with 327 additions and 136 deletions

View File

@@ -1,6 +1,9 @@
package util
import "os"
import (
"os"
"path/filepath"
)
// Exists reports whether the named file or directory exists.
func Exists(name string) bool {
@@ -11,3 +14,17 @@ func Exists(name string) bool {
}
return true
}
// CreatNestedFile 给定path创建文件如果目录不存在就递归创建
func CreatNestedFile(path string) (*os.File, error) {
basePath := filepath.Dir(path)
if !Exists(basePath) {
err := os.MkdirAll(basePath, 0700)
if err != nil {
Log().Warning("无法创建目录,%s", err)
return nil, err
}
}
return os.Create(path)
}