2014-07-21 14:12:49 +08:00
|
|
|
package weed_server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2014-10-27 02:34:55 +08:00
|
|
|
|
2016-06-03 09:09:14 +08:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
2014-07-21 14:12:49 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
/*
|
|
|
|
Move a folder or a file, with 4 Use cases:
|
2014-07-21 14:17:29 +08:00
|
|
|
mv fromDir toNewDir
|
|
|
|
mv fromDir toOldDir
|
|
|
|
mv fromFile toDir
|
|
|
|
mv fromFile toFile
|
2014-07-21 14:12:49 +08:00
|
|
|
|
|
|
|
Wildcard is not supported.
|
|
|
|
|
|
|
|
*/
|
|
|
|
func (fs *FilerServer) moveHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
from := r.FormValue("from")
|
|
|
|
to := r.FormValue("to")
|
|
|
|
err := fs.filer.Move(from, to)
|
|
|
|
if err != nil {
|
|
|
|
glog.V(4).Infoln("moving", from, "->", to, err.Error())
|
2015-01-08 16:19:32 +08:00
|
|
|
writeJsonError(w, r, http.StatusInternalServerError, err)
|
2014-07-21 14:12:49 +08:00
|
|
|
} else {
|
|
|
|
w.WriteHeader(http.StatusOK)
|
|
|
|
}
|
|
|
|
}
|
2016-07-21 14:45:55 +08:00
|
|
|
|
|
|
|
func (fs *FilerServer) registerHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
path := r.FormValue("path")
|
|
|
|
fileId := r.FormValue("fileId")
|
|
|
|
err := fs.filer.CreateFile(path, fileId)
|
|
|
|
if err != nil {
|
|
|
|
glog.V(4).Infof("register %s to %s error: %v", fileId, path, err)
|
|
|
|
writeJsonError(w, r, http.StatusInternalServerError, err)
|
|
|
|
} else {
|
|
|
|
w.WriteHeader(http.StatusOK)
|
|
|
|
}
|
|
|
|
}
|