ref: remove debug output

This commit is contained in:
Leon Richardt 2020-10-27 17:24:10 +01:00
parent 2b9de72507
commit 19576ac602
No known key found for this signature in database
GPG key ID: AD8BDD6273FE8FC5

View file

@ -16,7 +16,6 @@ type uploadHandler struct {
func (h *uploadHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (h *uploadHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close() defer r.Body.Close()
log.Println("request received from " + r.RemoteAddr)
uploadFile, header, err := r.FormFile("file") uploadFile, header, err := r.FormFile("file")
if err != nil { if err != nil {
@ -26,14 +25,12 @@ func (h *uploadHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
} }
defer uploadFile.Close() defer uploadFile.Close()
originalName, fileExtension := splitFileName(header.Filename) _, fileExtension := splitFileName(header.Filename)
log.Println(" received file: " + originalName)
// Find an unused file name // Find an unused file name
fileID := createRandomFileName(h.config.LinkLength) fileID := createRandomFileName(h.config.LinkLength)
for ; savedFileNames.Contains(fileID); fileID = createRandomFileName(h.config.LinkLength) { for ; savedFileNames.Contains(fileID); fileID = createRandomFileName(h.config.LinkLength) {
} }
log.Println(" generated random id: " + fileID)
fullFileName := fileID + fileExtension fullFileName := fileID + fileExtension
savePath := h.config.FileDir + fullFileName savePath := h.config.FileDir + fullFileName
@ -46,7 +43,6 @@ func (h *uploadHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return return
} }
savedFileNames.Insert(fullFileName) savedFileNames.Insert(fullFileName)
log.Println(" saved file as: " + fullFileName)
// Implicitly means code 200 // Implicitly means code 200
w.Write([]byte(link)) w.Write([]byte(link))