views:

38

answers:

2

Hi,

Is it possible to copy images into a static directory under my app engine project domain?

For example, when a user signs up for my app, I want them to supply an image for themselves, and I would copy it to a static directory but rename the image using their username, like:

www.mysite.com/imgs/username.jpg
www.mysite.com/imgs/john.jpg
www.mysite.com/imgs/jane.jpg

but I don't know where to start with this, since the JDO api doesn't really deal with this sort of thing (I think using JDO, they'd want me to store the image data as a blob associated with my User objects). Can I just upload the images to a static directory like this?

Thanks

+3  A: 

No. App Engine has a provision for static files, but only static files you upload along with your code. If users can upload the data, it is not really "static" in the app engine context. Depending on how large a picture you want users to be able to upload, you will want to use either the regular datastore (for storing up to 1MB) or the Blobstore for bigger files (up to 2 gig)

Peter Recore
Google has a tutorial about storing images in the datastore. http://code.google.com/appengine/docs/python/images/
mcotton
A: 

I'm almost certain you need to use the blobstore for dynamic upload. Even if you need not, for reasons of session independence you probably want to. As blobstore operations are expensive relative to a static file, you could have a task queue move the (now static) images into static store.

msw
Oh bummer, ok maybe i'll just host user images on a separate server or something then, thanks.
@msw, I think you are incorrect. You can use either the "normal" datastore or the blobstore for uploads. The only limitation with the normal datastore is total entity size. Also, how are you proposing to use the task queue to move the files from the blobstore into the static filesystem? And how are you going to get around the limit of 3000 total files per app?
Peter Recore
Your point about session independence is a good one though :)
Peter Recore
@Peter, you were correct about the limit of 3k static files which I was imagining could be dumped from blob/datastore to the developer's machine and bulk re-uploaded. But from my reading now, that 3k files is a mutable-but-not-really limitation of GAE as they don't like static files. If the OP is trying to re-write flickr in GAE, he should be willing to pay for the extra store, but probably isn't.
msw
@user246114 if its public site , gravatar is good.
iamgopal