Skip to content

Commit

Permalink
Strip url from special characters
Browse files Browse the repository at this point in the history
  • Loading branch information
blagojabozinovski committed Jul 19, 2024
1 parent 4481a32 commit 3f97b73
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ckanext/bulkupload/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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',
}

Expand All @@ -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)
Expand Down

0 comments on commit 3f97b73

Please sign in to comment.