go - open _rels/.rels: permission denied golang -


i trying unzip .docx file. first file of name "[content_types].xml" has been extracted. encountered error follows:

open frontend/uploads/doc_data/_rels/.rels: permission denied

how can set permission this?

the unzip function use follows:

func unzip(src, dest string) error {    r, err := zip.openreader(src)    if err != nil {        return err    }    defer r.close()    _, f := range r.file {        rc, err := f.open()        if err != nil {            return err        }        defer rc.close()        fpath := filepath.join(dest, f.name)        if f.fileinfo().isdir() {            os.mkdirall(fpath, f.mode())        } else {            var fdir string            if lastindex := strings.lastindex(fpath,string(os.pathseparator)); lastindex > -1 {                fdir = fpath[:lastindex]            }            err = os.mkdirall(fdir, f.mode())            if err != nil {                log.fatal(err)                return err            }            f, err := os.openfile(                fpath, os.o_wronly|os.o_create|os.o_trunc, f.mode())            if err != nil {                return err            }            defer f.close()            _, err = io.copy(f, rc)            if err != nil {                return err            }        }    }    return nil } 

try using chmod function of os package set file permissions allows want.

 err := os.chmod("file.txt", 0777)  if err != nil {      fmt.println(err)  } 

more info here : https://socketloop.com/tutorials/golang-change-file-read-or-write-permission-example


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -