I am trying to figure out a way where I can create a tab-delimited file containing data from user-defined fields and allow the user to download that file on google app engine.
The sandbox environment that the app runs in does not allow the application to write to disk. Is there another way where I can create a downloadable file?
You can download the Google App Engine SDK by going to: http://code.google.com/appengine/downloads.html and download the appropriate install package. Download the Windows installer – the simplest thing is to download it to your Desktop or another folder that you remember.
Sure there is! You can output your data as csv
, for instance. All you need to do is to change the Content-Type
header.
It's something like this:
class Test(webapp.RequestHandler):
def get(self, upload_type):
self.response.headers['Content-Type'] = 'text/csv'
self.response.out.write(','.join(['a', 'cool', 'test']))
In addition to jbochi's answer, you can also add a Content-Disposition header to save using a particular filename.
self.response.headers['Content-Disposition'] = "attachment; filename=fname.csv"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With