Exemplo n.º 1
0
func (self *restContext) ReadBucketId(value *httpserver.Values, key string, optional bool) (
	bucketId bucket.Id,
	bucketIdAsString string,
	status retcode.Status) {

	if optional {
		bucketIdAsString = value.OptionalString(key)
		if bucketIdAsString == "" {
			return
		}
	} else {
		bucketIdAsString, status = value.NonEmptyString(key)
		if !status.IsOk() {
			return
		}
	}

	bucketIdBytes, err := encoding.Base32Decode(bucketIdAsString)
	if err != nil {
		status = retcode.NewStatusFmt(retcode.ErrorClient, "Invalid bucket id given. The id "+
			"has to be base32 without padding. Err: %v", err)
		return
	}
	bucketId = bucket.Id(bucketIdBytes)
	status = retcode.NewStatusOk()
	return
}
Exemplo n.º 2
0
func (self *restContext) ReadShaHashAsBinary(value *httpserver.Values, key string) (
	hashBytes []byte,
	hashString string,
	status retcode.Status) {

	hashString, status = value.NonEmptyString(key)
	if !status.IsOk() {
		return
	}
	hashBytes, err := encoding.Base32Decode(hashString)
	if err != nil {
		status = retcode.NewStatusFmt(retcode.ErrorClient, "Invalid hash given. The hash "+
			"has to be base32 without padding. Err: %v", err)
		return
	}
	return
}
Exemplo n.º 3
0
func directorySubPath(params httpserver.Values, ctx *restContext) (ret []string) {
	ret = make([]string, 3)

	length := 0
	if params.Has("p0") {
		ret[0] = params.OptionalString("p0")
		length = 1
		if params.Has("p1") {
			ret[1] = params.OptionalString("p1")
			length = 2
			if params.Has("p2") {
				ret[2] = params.OptionalString("p2")
				length = 3
			}
		}
	}

	ret = ret[:length]
	return
}