如何使用 GAE 获取上传文件的文件名?
我只是将其上传到数据库(来自用户请求),如下所示:
x.file = db.Blob(self.request.get("img"))
如何获取文件名,我既有请求又有 blob,任何可以应用于其中任何一个的解决方案对我来说都可以
I just upload it to the db (coming from a user request) like this:
x.file = db.Blob(self.request.get("img"))
How do I get the filename, I have both the request and the blob, any solution that could be applied for any of them is ok for me
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
self.request.get("img")
返回的对象将有一个名为filename
的属性。当然,假设“img”是文件上传。The object that is returned by
self.request.get("img")
will have a property calledfilename
. Assuming that "img" is a file upload, of course.您必须使用 BlobstoreUploadHandler 返回的 BlobInfo
如此处所述
http://code.google.com/appengine/docs/python /tools/webapp/blobstorehandlers.html
它有一个文件名属性,如此处所述
http://code.google.com/appengine/docs/python/blobstore /blobinfoclass.html
you have to use the BlobInfo returned by BlobstoreUploadHandler
as described here
http://code.google.com/appengine/docs/python/tools/webapp/blobstorehandlers.html
it has a filename attribute as described here
http://code.google.com/appengine/docs/python/blobstore/blobinfoclass.html