mirror of
https://github.com/minoplhy/chibisafe-netproxy.git
synced 2024-12-22 10:08:08 +00:00
fix : code cleanup
This commit is contained in:
parent
c45dbce606
commit
2c2f6a24d2
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
uploads
|
||||
activity.log
|
||||
activity.log
|
||||
docker-compose.yml
|
9
main.go
9
main.go
@ -90,7 +90,7 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||
FileSize: fileHeader.Size,
|
||||
}
|
||||
|
||||
chibisafe_post, err := handler.UploadPost(Chibisafe_basepath, PostData, API_Key)
|
||||
chibisafe_post, err := handler.UploadPost(Chibisafe_basepath, API_Key, PostData)
|
||||
if err != nil {
|
||||
http.Error(w, handler.ErrorResponseBuild(http.StatusBadRequest, "Something went wrong!"), http.StatusBadRequest)
|
||||
handler.LogBuilder("ERROR", []string{r.RemoteAddr, tempfilepath}, err.Error())
|
||||
@ -114,13 +114,18 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
handler.LogBuilder("INFO", []string{r.RemoteAddr, chibisafe_Response_Metadata.Identifier, tempfilepath}, "Successfully PUT file to Network Storage")
|
||||
|
||||
// Build Struct for PostProcess Json
|
||||
//
|
||||
// Name -> original Filename
|
||||
// ContentType -> original Content-Type
|
||||
// Identifier -> File Identifier ID
|
||||
PostProcessData := handler.UploadProcessMeta{
|
||||
Name: fileHeader.Filename,
|
||||
ContentType: fileHeader.Header.Get("Content-Type"),
|
||||
Identifier: chibisafe_Response_Metadata.Identifier,
|
||||
}
|
||||
|
||||
PostProcess, err := handler.UploadProcessPost(Chibisafe_basepath, PostData.ContentType, chibisafe_Response_Metadata.Identifier, API_Key, PostProcessData)
|
||||
PostProcess, err := handler.UploadProcessPost(Chibisafe_basepath, API_Key, PostProcessData)
|
||||
if err != nil {
|
||||
http.Error(w, handler.ErrorResponseBuild(http.StatusInternalServerError, "Something went wrong!"), http.StatusInternalServerError)
|
||||
handler.LogBuilder("ERROR", []string{r.RemoteAddr, chibisafe_Response_Metadata.Identifier, tempfilepath}, err.Error())
|
||||
|
@ -27,7 +27,7 @@ func Check_API_Key(Basepath string, accessKey string) bool {
|
||||
return resp.StatusCode == http.StatusOK
|
||||
}
|
||||
|
||||
func UploadPost(BasePath string, PostData UploadPostMeta, accessKey string) ([]byte, error) {
|
||||
func UploadPost(BasePath string, accessKey string, PostData UploadPostMeta) ([]byte, error) {
|
||||
URL := BasePath + "/api/upload"
|
||||
// Convert PostData to JSON
|
||||
PostDataJson, err := json.Marshal(PostData)
|
||||
@ -110,7 +110,7 @@ func NetworkStoragePut(URL string, ContentType string, filepath string) ([]byte,
|
||||
}
|
||||
}
|
||||
|
||||
func UploadProcessPost(BasePath string, ContentType string, Identifier string, accessKey string, PostData UploadProcessMeta) ([]byte, error) {
|
||||
func UploadProcessPost(BasePath string, accessKey string, PostData UploadProcessMeta) ([]byte, error) {
|
||||
URL := BasePath + "/api/upload/process"
|
||||
// Convert PostData to JSON
|
||||
PostDataJson, err := json.Marshal(PostData)
|
||||
@ -124,10 +124,9 @@ func UploadProcessPost(BasePath string, ContentType string, Identifier string, a
|
||||
}
|
||||
|
||||
POSTStruct := URLRequest{
|
||||
URL: URL,
|
||||
ContentType: ContentType,
|
||||
Method: "POST",
|
||||
Header: headers,
|
||||
URL: URL,
|
||||
Method: "POST",
|
||||
Header: headers,
|
||||
}
|
||||
|
||||
resp, err := HTTPBytes(POSTStruct, bytes.NewBuffer(PostDataJson))
|
||||
|
Loading…
Reference in New Issue
Block a user