You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
970 B

11 years ago
  1. package weed_server
  2. import (
  3. "net/http"
  4. "github.com/chrislusf/seaweedfs/weed/glog"
  5. )
  6. /*
  7. Move a folder or a file, with 4 Use cases:
  8. mv fromDir toNewDir
  9. mv fromDir toOldDir
  10. mv fromFile toDir
  11. mv fromFile toFile
  12. Wildcard is not supported.
  13. */
  14. func (fs *FilerServer) moveHandler(w http.ResponseWriter, r *http.Request) {
  15. from := r.FormValue("from")
  16. to := r.FormValue("to")
  17. err := fs.filer.Move(from, to)
  18. if err != nil {
  19. glog.V(4).Infoln("moving", from, "->", to, err.Error())
  20. writeJsonError(w, r, http.StatusInternalServerError, err)
  21. } else {
  22. w.WriteHeader(http.StatusOK)
  23. }
  24. }
  25. func (fs *FilerServer) registerHandler(w http.ResponseWriter, r *http.Request) {
  26. path := r.FormValue("path")
  27. fileId := r.FormValue("fileId")
  28. err := fs.filer.CreateFile(path, fileId)
  29. if err != nil {
  30. glog.V(4).Infof("register %s to %s error: %v", fileId, path, err)
  31. writeJsonError(w, r, http.StatusInternalServerError, err)
  32. } else {
  33. w.WriteHeader(http.StatusOK)
  34. }
  35. }