|
|
@ -713,7 +713,7 @@ func uploadFileHandler(writer http.ResponseWriter, req *http.Request) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
err := req.ParseMultipartForm(64 << 20) |
|
|
|
/*err := req.ParseMultipartForm(64 << 20) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
writer.WriteHeader(http.StatusBadRequest) |
|
|
|
writer.WriteHeader(http.StatusBadRequest) |
|
|
|
return |
|
|
|
return |
|
|
@ -748,14 +748,15 @@ func uploadFileHandler(writer http.ResponseWriter, req *http.Request) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else {*/ |
|
|
|
body, err := io.ReadAll(req.Body) |
|
|
|
body, err := io.ReadAll(req.Body) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
writer.WriteHeader(http.StatusBadRequest) |
|
|
|
writer.WriteHeader(http.StatusBadRequest) |
|
|
|
} |
|
|
|
} |
|
|
|
var pho []Photos |
|
|
|
var pho ImgUpload |
|
|
|
|
|
|
|
//var pho []Photos
|
|
|
|
json.Unmarshal(body, &pho) |
|
|
|
json.Unmarshal(body, &pho) |
|
|
|
} |
|
|
|
/*} |
|
|
|
if len(pho) == 0 { |
|
|
|
if len(pho) == 0 { |
|
|
|
log.Fatal("Error: Size of Array = 0") |
|
|
|
log.Fatal("Error: Size of Array = 0") |
|
|
|
writer.WriteHeader(http.StatusInternalServerError) |
|
|
|
writer.WriteHeader(http.StatusInternalServerError) |
|
|
@ -773,12 +774,12 @@ func uploadFileHandler(writer http.ResponseWriter, req *http.Request) { |
|
|
|
b, err := json.Marshal(res) |
|
|
|
b, err := json.Marshal(res) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Fatal("Error: ", err) |
|
|
|
log.Fatal("Error: ", err) |
|
|
|
} |
|
|
|
}*/ |
|
|
|
location := fmt.Sprintf("%s/%d", req.URL.String(), res.Id) |
|
|
|
location := fmt.Sprintf("%s", req.URL.String()) |
|
|
|
writer.Header().Set("Location:", location) |
|
|
|
writer.Header().Set("Location:", location) |
|
|
|
writer.Header().Set("Content-Type", "application/json") |
|
|
|
writer.Header().Set("Content-Type", "application/json") |
|
|
|
writer.WriteHeader(http.StatusCreated) |
|
|
|
writer.WriteHeader(http.StatusCreated) |
|
|
|
writer.Write(b) |
|
|
|
writer.Write(b) |
|
|
|
} |
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|