@@ -232,22 +232,24 @@ func (s *HTTPStaticServer) hUploadOrMkdir(w http.ResponseWriter, req *http.Reque
232232
233233 // Large file (>32MB) will store in tmp directory
234234 // The quickest operation is call os.Move instead of os.Copy
235+ // Note: it seems not working well
236+
235237 var copyErr error
236- if osFile , ok := file .(* os.File ); ok && fileExists (osFile .Name ()) {
237- tmpUploadPath := osFile .Name ()
238- osFile .Close () // Windows can not rename opened file
239- log .Printf ("Move %s -> %s" , tmpUploadPath , dstPath )
240- copyErr = os .Rename (tmpUploadPath , dstPath )
241- } else {
242- dst , err := os .Create (dstPath )
243- if err != nil {
244- log .Println ("Create file:" , err )
245- http .Error (w , "File create " + err .Error (), http .StatusInternalServerError )
246- return
247- }
248- _ , copyErr = io .Copy (dst , file )
249- dst .Close ()
238+ // if osFile, ok := file.(*os.File); ok && fileExists(osFile.Name()) {
239+ // tmpUploadPath := osFile.Name()
240+ // osFile.Close() // Windows can not rename opened file
241+ // log.Printf("Move %s -> %s", tmpUploadPath, dstPath)
242+ // copyErr = os.Rename(tmpUploadPath, dstPath)
243+ // } else {
244+ dst , err := os .Create (dstPath )
245+ if err != nil {
246+ log .Println ("Create file:" , err )
247+ http .Error (w , "File create " + err .Error (), http .StatusInternalServerError )
248+ return
250249 }
250+ _ , copyErr = io .Copy (dst , file )
251+ dst .Close ()
252+ // }
251253 if copyErr != nil {
252254 log .Println ("Handle upload file:" , err )
253255 http .Error (w , err .Error (), http .StatusInternalServerError )
0 commit comments