I am trying to upload a file in my GAE app. How do I the upload of a file in Google App Engine using Go and using the r.FormValue()
?

在GAE Go中上传文件
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
4条回答 默认 最新
- douyun7718 2013-02-18 13:53关注
I managed to solve my problem by using the middle return param, "other". These code below are inside the upload handler
blobs, other, err := blobstore.ParseUpload(r)
Then assign corresponding formkey
file := blobs["file"] **name := other["name"]** //name is a form field **description := other["description"]** //descriptionis a form field
And use it like this in my struct value assignment
newData := data{ Name: **string(name[0])**, Description: **string(description[0])**, Image: string(file[0].BlobKey), } datastore.Put(c, datastore.NewIncompleteKey(c, "data", nil), &newData )
Not 100% sure this is the right thing but this solves my problem and it is now uploading the image to blobstore and saving other data and blobkey to datastore.
Hope this could help others too.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报