Exemplo n.º 1
0
 def download_file(self, object_type, name_or_id, filename=None):
     '''Download file from CKAN's filestore, grouped under `object_type` and
     identified by `name_or_id` inside this group.
     '''
     
     filepath = None
     if object_type == 'resources':
         up = uploader.ResourceUpload(resource={})
         filepath = up.get_path(name_or_id)
         app = fileapp.FileApp(filepath)
     elif object_type == 'source-metadata':
         up = uploader.MetadataUpload()
         filepath = up.get_path(name_or_id)
         app = fileapp.FileApp(filepath)
     elif object_type == 'metadata':
         val = get_cache('metadata').get(name_or_id)
         app = fileapp.DataApp(val, content_type='application/xml; charset=utf-8') 
     else:
         abort(404, 'Unknown object-type')
     
     # Retreive file
     try:
         status, headers, app_it = request.call_application(app)
     except:
         abort(404, 'Not Found')
     response.headers.update(dict(headers))
     response.status = status
     # Dump
     return app_it
Exemplo n.º 2
0
 def download_file(self, object_type, name_or_id, filename=None):
     '''Download file from CKAN's filestore, grouped under `object_type` and
     identified by `name_or_id` inside this group.
     '''
     
     filepath = None
     if object_type == 'resources':
         up = uploader.ResourceUpload(resource={})
         filepath = up.get_path(name_or_id)
         app = fileapp.FileApp(filepath)
     elif object_type == 'source-metadata':
         up = uploader.MetadataUpload()
         filepath = up.get_path(name_or_id)
         app = fileapp.FileApp(filepath)
     elif object_type == 'metadata':
         val = get_cache('metadata').get(name_or_id)
         app = fileapp.DataApp(val, content_type='application/xml; charset=utf-8') 
     else:
         abort(404, 'Unknown object-type')
     
     # Retreive file
     try:
         status, headers, app_it = request.call_application(app)
     except:
         abort(404, 'Not Found')
     response.headers.update(dict(headers))
     response.status = status
     # Dump
     return app_it
Exemplo n.º 3
0
    def _send_file_response(self, filepath, resource_name):
        user_filename = '_'.join(filepath.split('/')[-2:])
        file_size = os.path.getsize(filepath)

        headers = [('Content-Disposition',
                    'attachment; filename=\"' + str(resource_name) + '.zip\"'),
                   ('Content-Type', 'text/html'),
                   ('Content-Length', str(file_size))]

        from paste.fileapp import FileApp

        fapp = FileApp(filepath, headers=headers)
        status, headers, app_it = request.call_application(fapp)
        response.headers = headers
        response.status = status
        return app_it
Exemplo n.º 4
0
    def _send_file_response(self, filepath, resource_name):
        user_filename = "_".join(filepath.split("/")[-2:])
        file_size = os.path.getsize(filepath)

        headers = [
            ("Content-Disposition", 'attachment; filename="' + str(resource_name) + '.zip"'),
            ("Content-Type", "text/html"),
            ("Content-Length", str(file_size)),
        ]

        from paste.fileapp import FileApp

        fapp = FileApp(filepath, headers=headers)
        status, headers, app_it = request.call_application(fapp)
        response.headers = headers
        response.status = status
        return app_it
Exemplo n.º 5
0
 def test_dataapp(self):
     from paste.fileapp import DataApp
     app = DataApp('Ababoua')
     status, headers, app_it = request.call_application(app)
     assert False
Exemplo n.º 6
0
 def test_dataapp(self):
     from paste.fileapp import DataApp
     app = DataApp('Ababoua')
     status, headers, app_it = request.call_application(app)
     assert False