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.

37 lines
971 B

  1. package weed_server
  2. import (
  3. "net/http"
  4. "github.com/chrislusf/seaweedfs/weed/glog"
  5. "github.com/chrislusf/seaweedfs/weed/filer2"
  6. "strconv"
  7. )
  8. func (fs *FilerServer) registerHandler(w http.ResponseWriter, r *http.Request) {
  9. path := r.FormValue("path")
  10. fileId := r.FormValue("fileId")
  11. fileSize, err := strconv.ParseUint(r.FormValue("fileSize"), 10, 64)
  12. if err != nil {
  13. glog.V(4).Infof("register %s to %s parse fileSize %s: %v", fileId, path, r.FormValue("fileSize"), err)
  14. writeJsonError(w, r, http.StatusInternalServerError, err)
  15. return
  16. }
  17. entry := &filer2.Entry{
  18. FullPath: filer2.FullPath(path),
  19. Attr: filer2.Attr{
  20. Mode: 0660,
  21. },
  22. Chunks: []filer2.FileChunk{{
  23. Fid: filer2.FileId(fileId),
  24. Size: fileSize,
  25. }},
  26. }
  27. err = fs.filer.CreateEntry(entry)
  28. if err != nil {
  29. glog.V(4).Infof("register %s to %s error: %v", fileId, path, err)
  30. writeJsonError(w, r, http.StatusInternalServerError, err)
  31. } else {
  32. w.WriteHeader(http.StatusOK)
  33. }
  34. }