aboutsummaryrefslogtreecommitdiff
path: root/weed/operation/filer/register.go
blob: d45fd4f35a6e4a9ada0c044e5f14c220ed0e459b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package filer

import (
	"fmt"
	"net/url"

	"github.com/chrislusf/seaweedfs/weed/security"
	"github.com/chrislusf/seaweedfs/weed/util"
)

type SubmitResult struct {
	FileName string `json:"fileName,omitempty"`
	FileUrl  string `json:"fileUrl,omitempty"`
	Fid      string `json:"fid,omitempty"`
	Size     uint32 `json:"size,omitempty"`
	Error    string `json:"error,omitempty"`
}

func RegisterFile(filer string, path string, fileId string, secret security.Secret) error {
	// TODO: jwt need to be used
	_ = security.GenJwt(secret, fileId)

	values := make(url.Values)
	values.Add("path", path)
	values.Add("fileId", fileId)
	_, err := util.Post("http://"+filer+"/admin/register", values)
	if err != nil {
		return fmt.Errorf("Failed to register path %s on filer %s to file id %s : %v", path, filer, fileId, err)
	}
	return nil
}