The same logic used to load images applies to other types of archives. To make the file downloadable, you add a header Content-Dispositionso that the user receives a request to download it. An example of a simple webapp:
class DownloadHandler(webapp.RequestHandler):
def get(self, file_id):
f = Files.get_by_id(file_id)
if not f:
return self.error(404)
headers = self.response.headers
headers['Content-Type'] = f.content_type or 'application/octet-stream'
headers['Content-Disposition'] = 'attachment; filename="%s"' % f.filename
self.response.out.write(f.contents)
(untested code, but you get the idea :)
source
share