From dcc3dcfbc951dc84c64c044cabb94cbc6ca14e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=BC=A0?= Date: Mon, 31 Dec 2018 11:26:51 +0800 Subject: [PATCH] Update fileserver.go --- fileserver.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fileserver.go b/fileserver.go index a159ff7..373dc7a 100644 --- a/fileserver.go +++ b/fileserver.go @@ -499,6 +499,13 @@ func (this *Server) Upload(w http.ResponseWriter, r *http.Request) { md5sum = util.GetFileMd5(uploadFile) + if info, _ := this.GetFileInfoByMd5(md5sum); info != nil && info.Path != "" && info.Path != folder { + os.Remove(folder + "/" + name) + download_url := fmt.Sprintf("http://%s/%s", r.Host, info.Path+"/"+info.Name) + w.Write([]byte(download_url)) + return + } + } else { v := util.GetFileMd5(uploadFile)