Image Upload in Google App Engine

2019-02-19 19:36发布

I am working on a website where the user can upload a post relating to a location and then they can add two or three photos to go along with it. I understand how to do a basic upload with either the Datastore or the Blobstore but I want to link these photos to the post and to the user and then be able to display them in all pages connected to the post and the user.

That is the general idea but to be more specific I am trying to figure out if it would be easier to just to give the post entities 3 db.blob attributes and take a little hit on higher data costs or if it is doable to link the Blobstore entities with my Datastore entities.

2条回答
地球回转人心会变
2楼-- · 2019-02-19 19:39

Here is a full example of uploading photo and associating it to user.

To associate users and photos it uses creates class UserPhoto that links user ID and photo blob keys.

查看更多
萌系小妹纸
3楼-- · 2019-02-19 19:51

That's what BlobReferenceProprty is for. You can add a reference to a blob into model which seems to be what you want.

查看更多
登录 后发表回答