From fa9dcdc82a6b7506609bae95d6ec94c94b404fbf Mon Sep 17 00:00:00 2001 From: Gonzalo Fernandez-Victorio Date: Fri, 30 Apr 2021 14:42:00 +0100 Subject: [PATCH] Improve doc on parse --- docxlib.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docxlib.go b/docxlib.go index 2ed58d0..db93c23 100644 --- a/docxlib.go +++ b/docxlib.go @@ -22,6 +22,32 @@ func New() *DocxLib { } // Parse generates a new docx file in memory from a reader +// You can it invoke from a file +// readFile, err := os.Open(FILE_PATH) +// if err != nil { +// panic(err) +// } +// fileinfo, err := readFile.Stat() +// if err != nil { +// panic(err) +// } +// size := fileinfo.Size() +// doc, err := docxlib.Parse(readFile, int64(size)) +// but also you can invoke from a webform (BEWARE of trusting users data!!!) +// +// func uploadFile(w http.ResponseWriter, r *http.Request) { +// r.ParseMultipartForm(10 << 20) +// +// file, handler, err := r.FormFile("file") +// if err != nil { +// fmt.Println("Error Retrieving the File") +// fmt.Println(err) +// http.Error(w, err.Error(), http.StatusBadRequest) +// return +// } +// defer file.Close() +// docxlib.Parse(file, handler.Size) +// } func Parse(reader io.ReaderAt, size int64) (doc *DocxLib, err error) { zipReader, err := zip.NewReader(reader, size) if err != nil {