diff --git a/ckanext/odsh/logic/action.py b/ckanext/odsh/logic/action.py index 0b4402dbcc986b67f8c91964d4c15820785c0172..a4cf48d8adb682efdb4058757d83918fc14a3f6c 100644 --- a/ckanext/odsh/logic/action.py +++ b/ckanext/odsh/logic/action.py @@ -5,6 +5,7 @@ import ckan.model as model import ckan.lib.dictization.model_dictize as model_dictize from ckan.lib.munge import munge_title_to_name import ckan.plugins.toolkit as toolkit +from pylons import config from ckan.lib.search.common import make_connection, SearchError import pysolr import datetime @@ -147,10 +148,14 @@ def autocomplete(context, data_dict): def odsh_resource_create(context, data_dict): - is_linked_resource = not isinstance(data_dict['upload'], cgi.FieldStorage) - if is_linked_resource: - _download_linked_resource_to_tmp(data_dict['url']) - _emulate_file_upload(data_dict) + copy_remote_resources = toolkit.asbool( + config.get('ckanext.odsh.copy_remote_resources', 'False') + ) + if copy_remote_resources: + is_linked_resource = ( not 'upload' in data_dict ) or ( not isinstance(data_dict['upload'], cgi.FieldStorage)) + if is_linked_resource: + _download_linked_resource_to_tmp(data_dict['url']) + _emulate_file_upload(data_dict) return resource_create(context, data_dict) TMP_FILE_PATH = '/tmp/temp_file_upload' @@ -181,4 +186,4 @@ def _emulate_file_upload(data_dict): upload.headers['content-type'] = upload.type upload.name = 'upload' upload.filename = filename - data_dict['upload'] = upload \ No newline at end of file + data_dict['upload'] = upload