Exemplo n.º 1
0
func NewRsf(baseDir string) (*Rsf, error) {
	// load config
	conf := Config{}
	err := loadJsonFile(&conf, baseDir+"/qrsb.conf")
	if err != nil {
		log.Error("load qrsb.conf file error!")
		return nil, err
	}
	log.Info("use conf of:", conf)
	t := digest_auth.NewTransport(conf.AccessKey, conf.SecretKey, nil)
	rsfs := rsf.New(t, conf.RsfHost)
	RS_HOST = conf.RsHost
	rss := rs.New(t)
	return &Rsf{&conf, baseDir, rsfs, rss}, nil
}
Exemplo n.º 2
0
func main() {
	if len(os.Args) != 4 {
		log.Fatal("args is not right.")
	}
	access, secret, fName := os.Args[1], os.Args[2], os.Args[3]
	transport := digest_auth.NewTransport(access, secret, nil)
	rsServer := rs.New(transport)
	f, err := os.Open(fName)
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()
	fInfo, err := os.Stat(fName)
	if err != nil {
		log.Fatal(err)
	}
	fSize := fInfo.Size()

	_, _, err = rsServer.Put("aprilshot:"+fName, "image/png", f, fSize, "", "", "")
	if err != nil {
		log.Fatal(err)
	}
}