register.go 829 B

12345678910111213141516171819202122232425262728293031
  1. package filer
  2. import (
  3. "fmt"
  4. "net/url"
  5. "github.com/chrislusf/seaweedfs/weed/security"
  6. "github.com/chrislusf/seaweedfs/weed/util"
  7. )
  8. type SubmitResult struct {
  9. FileName string `json:"fileName,omitempty"`
  10. FileUrl string `json:"fileUrl,omitempty"`
  11. Fid string `json:"fid,omitempty"`
  12. Size uint32 `json:"size,omitempty"`
  13. Error string `json:"error,omitempty"`
  14. }
  15. func RegisterFile(filer string, path string, fileId string, secret security.Secret) error {
  16. // TODO: jwt need to be used
  17. _ = security.GenJwt(secret, fileId)
  18. values := make(url.Values)
  19. values.Add("path", path)
  20. values.Add("fileId", fileId)
  21. _, err := util.Post("http://"+filer+"/admin/register", values)
  22. if err != nil {
  23. return fmt.Errorf("Failed to register path %s on filer %s to file id %s : %v", path, filer, fileId, err)
  24. }
  25. return nil
  26. }