forked from jason/cpolis
Create WriteFile() so backend handles files
This commit is contained in:
@ -2,10 +2,8 @@ package frontend
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/google/uuid"
|
||||
@ -60,15 +58,7 @@ func UploadPDF(c *b.Config, s *b.CookieStore) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
pdf, err := os.Create(absFilepath)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
defer pdf.Close()
|
||||
|
||||
if _, err = io.Copy(pdf, file); err != nil {
|
||||
if err = b.WriteFile(absFilepath, file); err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
|
Reference in New Issue
Block a user