Beispiel #1
0
func (s *Service) mkObject(o *fs.Object) (code int, err error) {
	var (
		ctx string
	)
	for k, p := range o.Progress {
		if k == len(o.Progress)-1 {
			ctx += p.Ctx
		} else {
			ctx += p.Ctx + ","
		}
	}
	bd := []byte(ctx)
	url := s.Host["up"] + "/rs-mkfile/" + EncodeURI(o.EntryURI) + "/fsize/" + strconv.FormatInt(o.Size, 10)
	code, err = s.Conn.CallWith(nil, url, "", bytes.NewReader(bd), len(bd))
	return
}
Beispiel #2
0
func Checksum(req *http.Request, key []byte, incbody bool) (digest string, err error) {

	h := hmac.New(sha1.New, key)

	u := req.URL
	data := u.Path
	if u.RawQuery != "" {
		data += "?" + u.RawQuery
	}
	io.WriteString(h, data+"\n")

	if incbody {
		b, _ := ioutil.ReadAll(req.Body)
		req.Body = bytes.NewReader(b)
		h.Write(b)
	}
	digest = base64.URLEncoding.EncodeToString(h.Sum(nil))
	return
}