Beispiel #1
0
func Mkfile(
	c rpc.Client, l rpc.Logger, ret interface{}, key string, hasKey bool, fsize int64, extra *PutExtra) (err error) {

	url := UP_HOST + "/mkfile/" + strconv.FormatInt(fsize, 10)

	if extra.MimeType != "" {
		url += "/mimeType/" + encode(extra.MimeType)
	}
	if hasKey {
		url += "/key/" + encode(key)
	}
	for k, v := range extra.Params {
		url += fmt.Sprintf("/%s/%s", k, encode(v))
	}

	buf := make([]byte, 0, 176*len(extra.Progresses))
	for _, prog := range extra.Progresses {
		buf = append(buf, prog.Ctx...)
		buf = append(buf, ',')
	}
	if len(buf) > 0 {
		buf = buf[:len(buf)-1]
	}

	return c.CallWith(l, ret, url, "application/octet-stream", bytes.NewReader(buf), len(buf))
}
Beispiel #2
0
func Blockput(
	c rpc.Client, l rpc.Logger, ret *BlkputRet, body io.Reader, size int) error {

	url := ret.Host + "/bput/" + ret.Ctx + "/" + strconv.FormatUint(uint64(ret.Offset), 10)
	return c.CallWith(l, ret, url, "application/octet-stream", body, size)
}
Beispiel #3
0
func Mkblock(
	c rpc.Client, l rpc.Logger, ret *BlkputRet, blockSize int, body io.Reader, size int) error {

	return c.CallWith(l, ret, UP_HOST+"/mkblk/"+strconv.Itoa(blockSize), "application/octet-stream", body, size)
}