Skip to content

Commit

Permalink
fix local dir error
Browse files Browse the repository at this point in the history
  • Loading branch information
txthinking committed Aug 8, 2019
1 parent 4840856 commit b8e4ae1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cli/cloudupload/main.go
Expand Up @@ -25,7 +25,7 @@ var debugListen string
func main() {
app := cli.NewApp()
app.Name = "Cloud Upload"
app.Version = "20181008"
app.Version = "20190808"
app.Usage = "Upload files to multiple cloud storage in parallel"
app.Author = "Cloud"
app.Email = "cloud@txthinking.com"
Expand Down
7 changes: 7 additions & 0 deletions local.go
Expand Up @@ -3,13 +3,20 @@ package cloudupload
import (
"io"
"os"
"strings"
)

type Local struct {
StoragePath string
}

func (l *Local) Save(name string, r io.Reader) error {
i := strings.LastIndex(name, "/")
if i != -1 {
if err := os.MkdirAll(l.StoragePath+"/"+name[0:i], 0740); err != nil {
return err
}
}
var f *os.File
f, err := os.OpenFile(l.StoragePath+"/"+name, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
if err != nil {
Expand Down

0 comments on commit b8e4ae1

Please sign in to comment.