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 }
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 }