From 3f97b736e8c967bce65e487fcbbf9a285aaf08c1 Mon Sep 17 00:00:00 2001 From: blagoja Date: Fri, 19 Jul 2024 22:04:39 +0200 Subject: [PATCH] Strip url from special characters --- ckanext/bulkupload/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ckanext/bulkupload/views.py b/ckanext/bulkupload/views.py index a3b7db9..3cf6c4a 100644 --- a/ckanext/bulkupload/views.py +++ b/ckanext/bulkupload/views.py @@ -6,6 +6,7 @@ import ckan.lib.base as base import logging import os +import re from pathlib import Path import boto3 from botocore.exceptions import ClientError @@ -170,10 +171,11 @@ def bulk_resource_upload(pkg_name): #The for loop stays for future multi files upload posibility for f in uploaded_files: + url_striped = re.sub(r"[)()]+", "", f.filename) data_dict = { 'package_id': pkg_name, 'name': f.filename, - 'url': f.filename, + 'url': url_striped, 'url_type': 'upload', } @@ -182,7 +184,7 @@ def bulk_resource_upload(pkg_name): file_name = os.path.join(storage_path, unique_filename) f.save(file_name) - object_name = '/resources/' + x['id'] + '/' + f.filename + object_name = '/resources/' + x['id'] + '/' + url_striped try: response = s3_client.upload_file(file_name, bucket, object_name)