Skip to content

Commit

Permalink
refactor(main): call the new features from the main file
Browse files Browse the repository at this point in the history
  • Loading branch information
danvergara committed Jan 21, 2024
1 parent 240dfde commit 3f3a879
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func handleUploadFile(w http.ResponseWriter, r *http.Request) {
return
}

fileFactory, err := files.BuildFactory(fileType)
fileFactory, err := files.BuildFactory(fileType, fileHeader.Filename)
if err != nil {
log.Printf("error occurred while getting a file factory: %v", err)
renderError(w, "INVALID_FILE", http.StatusBadRequest)
Expand All @@ -135,6 +135,10 @@ func handleUploadFile(w http.ResponseWriter, r *http.Request) {
return
}

if fileType == "application" {
targetFileSubType = "zip"
}

convertedFileName = filename(fileHeader.Filename, targetFileSubType)
convertedFilePath = filepath.Join(uploadPath, convertedFileName)

Expand Down Expand Up @@ -213,7 +217,7 @@ func handleFileFormat(w http.ResponseWriter, r *http.Request) {
return
}

fileFactory, err := files.BuildFactory(fileType)
fileFactory, err := files.BuildFactory(fileType, "")
if err != nil {
log.Printf("error occurred while getting a file factory: %v", err)
renderError(w, "INVALID_FILE", http.StatusBadRequest)
Expand Down

0 comments on commit 3f3a879

Please sign in to comment.