func Save(rw http.ResponseWriter, req *http.Request, r render.Render, params martini.Params) { ctx := appengine.NewContext(req) blobs, vals, err := blobstore.ParseUpload(req) if err != nil { http.Redirect(rw, req, "/admin/content/"+params["id"]+"?error="+err.Error(), http.StatusFound) return } var title string var body string var link string if len(vals["title"]) > 0 { title = vals["title"][0] } if len(vals["body"]) > 0 { body = vals["body"][0] } if len(vals["link"]) > 0 { link = vals["link"][0] } c := content.Content{} intID, err := strconv.Atoi(params["id"]) if err == nil { c.ID = int64(intID) } c.Get(ctx) c.Title = title c.Body = body c.Link = link file := blobs["image"] if len(file) != 0 { c.Image = fmt.Sprintf("/blob/%s", string(file[0].BlobKey)) } err = c.Save(ctx) if err != nil { http.Redirect(rw, req, "/admin/content/"+params["id"]+"?error="+err.Error(), http.StatusFound) return } http.Redirect(rw, req, "/admin/content/"+strconv.Itoa(int(c.ID))+"?success=Content saved", http.StatusFound) return }