# if a filename was specified; e.g. "downloads/myFile.tgz" # 'traverse_subpath' is a list like ['BinaryDataExample', 'downloads', 'myFile.tgz'] built by # splitting the URL 'BinaryDataExample/downloads/myFile.tgz' if len( traverse_subpath ) == 1: # e.g. filename = myFile.tgz filename = traverse_subpath[ 0 ] filedata = container.sql_getDownloadData( filename = filename )[0][0] # browser / proxy specific declarations; # see also the "index_html()" method in \lib\python\OFS\Image.py RESPONSE.setHeader( 'Content-Type', 'application/octet-stream' ) # tell the browser that it will receive bytes RESPONSE.setHeader( 'Accept-Ranges', 'bytes' ) # the next 2 lines are required: so downloading files will also work in older Netscape browsers RESPONSE.setHeader( 'Last-Modified', container.ZopeTime().rfc822() ) RESPONSE.setHeader( 'ETag', 'ts%s' % str( container.ZopeTime().timeTime() )[ 2: ] ) return filedata # incorrect call else: RESPONSE.redirect( 'index.html' ) |