func commonUploadResponse(configer blobserver.Configer, req *http.Request) (map[string]interface{}, error) { ret := make(map[string]interface{}) ret["maxUploadSize"] = blobserver.MaxBlobSize ret["uploadUrlExpirationSeconds"] = 86400 if configer == nil { err := errors.New("Cannot build uploadUrl: configer is nil") log.Printf("%v", err) return nil, err } else if config := configer.Config(); config != nil { // TODO: camli/upload isn't part of the spec. we should pick // something different here just to make it obvious that this // isn't a well-known URL and accidentally encourage lazy clients. baseURL, err := httputil.BaseURL(config.URLBase, req) if err != nil { errStr := fmt.Sprintf("Cannot build uploadUrl: %v", err) log.Printf(errStr) return ret, fmt.Errorf(errStr) } ret["uploadUrl"] = baseURL + "/camli/upload" } else { err := errors.New("Cannot build uploadUrl: configer.Config is nil") log.Printf("%v", err) return nil, err } return ret, nil }
func commonUploadResponse(configer blobserver.Configer, req *http.Request) map[string]interface{} { ret := make(map[string]interface{}) ret["maxUploadSize"] = 2147483647 // 2GB.. *shrug*. TODO: cut this down, standardize ret["uploadUrlExpirationSeconds"] = 86400 if configer == nil { ret["uploadUrl"] = "(Error: configer is nil)" } else if config := configer.Config(); config != nil { // TODO: camli/upload isn't part of the spec. we should pick // something different here just to make it obvious that this // isn't a well-known URL and accidentally encourage lazy clients. ret["uploadUrl"] = config.URLBase + "/camli/upload" } else { ret["uploadUrl"] = "(configer.Config is nil)" } return ret }