Can,
I have had a similar experience in using the Blobstore with Django-nonrel.
For your first question, the Blobstore is not overkill and I think is in fact the only way you can upload an image without updating your whole project and republishing it. GAE does not let you write to a directory because of the server's high replication and security. It's a trade off with being able to spin up all the servers automatically as demand increase. If you try to do anything that involves writing to a directory, App Engine will error.
I am looking for a better solution to your second question myself. I would like to be able to reference the file by name myself. The key I think will be adding an extra attribute to the "Upload" Model that gets set to the filename at save time. I have not tried it but it should work.
Update:
This worked.
Here is the Model:
class UploadModel(models.Model):
title = models.CharField(max_length=64, blank=True)
file = models.FileField(upload_to='uploads/%Y/%m/%d/%H/%M/%S/')
filename = models.CharField(max_length=100, editable=False, null=True, blank=True)
def save(self, *args, **kwargs):
self.filename = self.file.name.rsplit('/', 1)[-1]
super(UploadModel, self).save(*args, **kwargs)
here is the download handler:
def download_handler(request, filename):
upload = get_object_or_404(UploadModel, filename=filename)
return serve_file(request, upload.file, save_as=True)
the URL mapping:
url(r'^file/(?P<filename>.+)$', 'cms.views.download_handler_filename', name='cms-download_file'),
Once you do this you can access the file by filename (This is just a snippet from the example app). As you can see the 'pk' was replaced with the 'filename' attribute:
{% url cms-download_file filename=upload.filename as fallback_url %}
<p><img src="{% firstof upload.file|public_download_url fallback_url %}"></p>
What I am stuck on myself is getting 'public_download_url' to work with GAE Blobstore. If someone else can comment in with how to get a proper public backed to work that automatically generates the public URL I would greatly appreciate it.
Grant