Exemple #1
0
 def download(self, value):
     if not self.isAuthorized():
         raise cherrypy.HTTPError(401, 'Unauthorized')
     filelist = [filepath for filepath in json.loads(unquote(value))]
     dlstatus = self.download_check_files(filelist)
     if dlstatus == 'ok':
         _save_and_release_session()
         zipmime = 'application/x-zip-compressed'
         cherrypy.response.headers["Content-Type"] = zipmime
         zipname = 'attachment; filename="music.zip"'
         cherrypy.response.headers['Content-Disposition'] = zipname
         basedir = cherry.config['media.basedir']
         fullpath_filelist = [os.path.join(basedir, f) for f in filelist]
         return zipstream.ZipStream(fullpath_filelist)
     else:
         return dlstatus
Exemple #2
0
 def compress(self, filelist):
     fullpath_filelist = [
         cherry.config['media.basedir'] + f for f in filelist
     ]
     yield zipstream.ZipStream(fullpath_filelist)