如何操作谷歌应用程序引擎数据存储中的文件
我的问题围绕用户将文本文件上传到我的应用程序。我需要获取此文件并使用我的应用程序对其进行处理,然后再将其保存到数据存储区。从我所读到的一点来看,我了解到用户上传作为 blob 直接进入数据存储,如果我可以获取该文件,对其执行操作(意味着更改内部数据),然后将其重新写回,那就可以了数据存储。所有这些操作都需要由应用程序来完成。 遗憾的是,根据数据存储区文档,http://code.google.com/appengine /docs/python/blobstore/overview.html 应用程序无法直接在数据存储中创建 blob。这是我最头疼的问题。我只需要一种从我的应用程序在数据存储中创建新的 blob/文件的方法,而无需任何用户上传交互。
My problem revolves around a user making a text file upload to my app. I need to get this file and process it with my app before saving it to the datastore. From the little I have read, I understand that user uploads go directly to the datastore as blobs, which is ok if I could then get that file, perform operations on it(meaning change data inside) and then re-write it back to the datastore. All these operations need to be done by the app.
Unfortunately from the datastore documenation, http://code.google.com/appengine/docs/python/blobstore/overview.html
an app cannot directly create a blob in the datastore. That's my main headache. I simply need a way of creating a new blob/file in the datastore from my app without any user upload interaction.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
blobstore != 数据存储
。您可以根据需要在数据存储区中读取和写入数据,只要您使用
db.BlobProperty
在您的实体上。正如 Wooble 评论的那样,新的文件 API 可让您编写到blobstore,但除非您使用任务或类似mapreduce库的东西增量写入blobstore文件,否则您仍然受到1MB API调用限制用于阅读/写作。
blobstore != datastore
.You can read and write data to the datastore as much as you like so long as your data is <1MB using a
db.BlobProperty
on your entity.As Wooble comments, the new File API lets you write to the blobstore, but unless you are incrementally writting to the blobstore-file using tasks or something like the mapreduce library you are still limited by the 1MB API call limit for reading/writing.
感谢您的帮助。经过许多个不眠之夜、三本 App Engine 书籍和大量谷歌搜索后,我找到了答案。这是代码(它应该是非常不言自明的):
Thanks for your help. After many sleepless nights, 3 App Engine Books and A LOT of Googling, I've found the answer. Here is the code (it should be pretty self explanatory):