我尝试将图片上传到Google App Engine blobstore
除了文件字段,我在表单中还有其他一些字段(例如文章标题,内容......)。
我正在使用this answer中的解决方案,它正常工作,除了unicode
与其他字段的错误。
例如,"こんにちは"
在存储到数据存储区时变为"$B$3$s$K$A$O(B"
。这个问题的解决方法是什么?
更新
以下是我的代码
func handleSave(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
blobs, other_fields, err := blobstore.ParseUpload(r)
if err != nil {
serveError(c, w, err)
return
}
id := other_fields["id"][0]
categoryId, _ := strconv.ParseInt(other_fields["category_id"][0], 10, 64)
title := string(other_fields["title"][0])
content := []byte(other_fields["content"][0])
image := blobs["file"]
// ...
}