diff --git a/.gitignore b/.gitignore index 811096d..9d14b9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ uploads -activity.log \ No newline at end of file +activity.log +docker-compose.yml \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.example.yml similarity index 100% rename from docker-compose.yml rename to docker-compose.example.yml diff --git a/main.go b/main.go index d0ae473..a3c1657 100644 --- a/main.go +++ b/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()) diff --git a/src/handler/chibisafe.go b/src/handler/chibisafe.go index fc3360e..fd3f56f 100644 --- a/src/handler/chibisafe.go +++ b/src/handler/chibisafe.go @@ -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))