我正在尝试邮递员提供的这些代码,以将图像上传到blobstore。
blobstore.ParseUpload(r)这些方法未处理邮递员发送的任何请求。它显示为空。
错误:我收到类似“我没有上传文件”的错误
func init() {
initKeys()
http.HandleFunc("/api/image/", handleUpload)
}
func handleUpload(w http.ResponseWriter, r *http.Request){
ctx := appengine.NewContext(r)
blobs, _, err := blobstore.ParseUpload(r)
log.Infof(ctx, "blobs blobs", blobs)
if err != nil {
serveError(ctx, w, err)
return
}
file := blobs["file"]
log.Infof(ctx, "file file", file)
if len(file) == 0 {
log.Errorf(ctx, "no file uploaded")
//http.Redirect(w, r, "/", http.StatusFound)
return
}
http.Redirect(w, r, "/serve/?blobKey="+string(file[0].BlobKey), http.StatusFound)
}