GAE downloaded file extensions from blobstore
blobstore, google-app-engine, google-chrome, http-headers, internet-explorer
Solution
Ah, as per the comments at the top, the solution was to add the file extension onto the filename attribute in BlobInfo. I didn't initially realize this was necessary since Chrome automatically added the file extension when downloading.
Problem
I'm currently storing a bunch of .docx files in the GAE Blobstore. I recently noticed that these files are downloading without file extensions on some computers (IE 9 for Windows 7), but works fine for others (IE 8, Chrome for Windows 7). Here's how the files are stored in the blobstore: ``` f = files.blobstore.create(mime_type='application/vnd.openxmlformats-officedocument.wordprocessingml.document', _blobinfo_uploaded_filename=filename) ## then some code to write data and save ## ``` Here's the response headers for the file from the Chrome inspector: ``` Cache-Control:no-cache Content-Disposition:attachment; filename="causes_of_ww1_emanresu" Content-Length:12120 Content-Type:application/vnd.openxmlformats-officedocument.wordprocessingml.document Date:Fri, 26 Oct 2012 23:54:09 GMT Server:Google Frontend X-AppEngine-Estimated-CPM-US-Dollars:$0.000033 X-AppEngine-Resource-Usage:ms=15 cpu_ms=0 ``` Here's how I serve the blob: ``` self.send_blob(blob_info, save_as=blob_info.filename, content_type=blob_info.content_type) ``` I even tried hardcoding `content_type='application/vnd.openxmlformats-officedocument.wordprocessingml.document'` to no avail. Any ideas on what's going on and how to fix it? As requested, here's how I get the file information when initially saving the blob. I'm pretty certain that the error is not occuring at this level, but here's the precursor to the problem: ``` # get the file from a file_url with urlfetch result = urlfetch.fetch(file_url) headers = result.headers # some custom functions to return a filename username = self.get_username() filename = get_filename(title, username) # write the file to blobstore f = files.blobstore.create(mime_type=headers['content-type'], _blobinfo_uploaded_filename=filename) with files.open(f, 'a') as data: data.write(result.content) files.finalize(f) blob_key = files.blobstore.get_blob_key(f) ```