From 4481a321c4d251728d25d25abb3ac359f1081c99 Mon Sep 17 00:00:00 2001 From: blagoja Date: Fri, 19 Jul 2024 21:33:06 +0200 Subject: [PATCH] Upload unique file name --- ckanext/bulkupload/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ckanext/bulkupload/views.py b/ckanext/bulkupload/views.py index a0e3728..a3b7db9 100644 --- a/ckanext/bulkupload/views.py +++ b/ckanext/bulkupload/views.py @@ -9,7 +9,7 @@ from pathlib import Path import boto3 from botocore.exceptions import ClientError -import ckan.lib.munge as munge +import uuid from ckan.common import g from ckan.logic.action import get @@ -178,7 +178,8 @@ def bulk_resource_upload(pkg_name): } x = tk.get_action("resource_create")(context, data_dict) - file_name = os.path.join(storage_path, f.filename) + unique_filename = str(uuid.uuid4())[:8] + str(f.filename) + file_name = os.path.join(storage_path, unique_filename) f.save(file_name) object_name = '/resources/' + x['id'] + '/' + f.filename