mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-06-28 15:45:35 +08:00
remove .docx in name of directory
use /upload/filename(without .docx)/media/imagename.ext
This commit is contained in:
parent
247dbe8a2d
commit
6703b97a01
@ -152,7 +152,11 @@ func escape(s, set string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (zf *file) extract(rel *Relationship, w io.Writer) error {
|
func (zf *file) extract(rel *Relationship, w io.Writer) error {
|
||||||
err := os.MkdirAll(filepath.Join("uploads", zf.name, filepath.Dir(rel.Target)), 0755)
|
err := os.MkdirAll(
|
||||||
|
filepath.Join("uploads",
|
||||||
|
strings.TrimSuffix(zf.name, ".docx"),
|
||||||
|
filepath.Dir(rel.Target)),
|
||||||
|
0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -175,11 +179,18 @@ func (zf *file) extract(rel *Relationship, w io.Writer) error {
|
|||||||
fmt.Fprintf(w, "",
|
fmt.Fprintf(w, "",
|
||||||
base64.StdEncoding.EncodeToString(b[:n]))
|
base64.StdEncoding.EncodeToString(b[:n]))
|
||||||
} else {
|
} else {
|
||||||
err = ioutil.WriteFile(filepath.Join("uploads", zf.name, rel.Target), b, 0644)
|
err = ioutil.WriteFile(
|
||||||
|
filepath.Join("uploads",
|
||||||
|
strings.TrimSuffix(zf.name, ".docx"),
|
||||||
|
rel.Target),
|
||||||
|
b, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Fprintf(w, "", "/"+filepath.Join("uploads", zf.name, escape(rel.Target, "()")))
|
fmt.Fprintf(w, "", "/"+filepath.Join(
|
||||||
|
"uploads",
|
||||||
|
strings.TrimSuffix(zf.name, ".docx"),
|
||||||
|
escape(rel.Target, "()")))
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user