I have a model which *I want* to contain an image blob. I have the images on my local filesystem, but due to the nature of my application, I need to get them in the datastore. Here's my model:
我有一个*我希望*包含图像blob的模型。我在我的本地文件系统上有图像,但由于我的应用程序的性质,我需要在数据存储区中获取它们。这是我的模特:
class JeanImage(db.Model):
type = db.StringProperty(required=True, choices=set(["main","front","back","detail"]))
image = db.BlobProperty(required=True)
I haven't tried anything yet because I'm not great when dealing with images.
我还没有尝试任何东西,因为在处理图像时我不是很好。
How can/should I convert my images to blobs so that I can get them in my bulkupload csv file?
我怎么能/应该将我的图像转换为blob,以便我可以在bulkupload csv文件中获取它们?
Mark
2 个解决方案
#1
You can do it, just not with the bulk uploader. You need to access the remote api directly.
你可以做到这一点,而不是批量上传者。您需要直接访问远程api。
This site has a basic example of how to use it: http://www.billkatz.com/2009/2/Remote-API-Hello-World
该网站有一个如何使用它的基本示例:http://www.billkatz.com/2009/2/Remote-API-Hello-World
Its pretty slow and a good idea to have a retry mechanism.
它的速度非常慢,并且有一个重试机制。
A more detailed description can be found here: http://code.google.com/appengine/articles/remote_api.html
可以在此处找到更详细的说明:http://code.google.com/appengine/articles/remote_api.html
#2
I believe that what you are trying to achieve is not possible using the app engine bulkloader.
我相信使用应用引擎批量加载器无法实现您想要实现的目标。
Instead try to create some kind of uploader yourself. For example you could upload the images as a zip file and then extract it an store it in the datastore. The code for that should be fairly straightforward if you can map your images to the datastore entity (e.g. by using a naming convention).
而是尝试自己创建某种上传器。例如,您可以将图像作为zip文件上传,然后将其存储在数据存储区中。如果您可以将图像映射到数据存储区实体(例如,通过使用命名约定),那么代码应该相当简单。
#1
You can do it, just not with the bulk uploader. You need to access the remote api directly.
你可以做到这一点,而不是批量上传者。您需要直接访问远程api。
This site has a basic example of how to use it: http://www.billkatz.com/2009/2/Remote-API-Hello-World
该网站有一个如何使用它的基本示例:http://www.billkatz.com/2009/2/Remote-API-Hello-World
Its pretty slow and a good idea to have a retry mechanism.
它的速度非常慢,并且有一个重试机制。
A more detailed description can be found here: http://code.google.com/appengine/articles/remote_api.html
可以在此处找到更详细的说明:http://code.google.com/appengine/articles/remote_api.html
#2
I believe that what you are trying to achieve is not possible using the app engine bulkloader.
我相信使用应用引擎批量加载器无法实现您想要实现的目标。
Instead try to create some kind of uploader yourself. For example you could upload the images as a zip file and then extract it an store it in the datastore. The code for that should be fairly straightforward if you can map your images to the datastore entity (e.g. by using a naming convention).
而是尝试自己创建某种上传器。例如,您可以将图像作为zip文件上传,然后将其存储在数据存储区中。如果您可以将图像映射到数据存储区实体(例如,通过使用命名约定),那么代码应该相当简单。