Skip to content

Commit

Permalink
Merge pull request #434 from vrk-kpa/LIKA-604_fix_adding_pdfs_to_perm…
Browse files Browse the repository at this point in the history
…ission_applications

LIKA-604: Fix adding pdfs to permission applications
  • Loading branch information
Zharktas authored Feb 23, 2024
2 parents f91e103 + a7f5583 commit de60aa5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/ckan/lib/uploader.py b/ckan/lib/uploader.py
index ec4a6dfd0..360ebfbe0 100644
--- a/ckan/lib/uploader.py
+++ b/ckan/lib/uploader.py
@@ -220,7 +220,7 @@ class Upload(object):
if not mimetypes and not types:
return

- actual = magic.from_buffer(self.upload_file.read(1024), mime=True)
+ actual = magic.from_buffer(self.upload_file.read(2048), mime=True)
self.upload_file.seek(0, os.SEEK_SET)
err = {self.file_field: [
"Unsupported upload type: {actual}".format(actual=actual)]}
4 changes: 4 additions & 0 deletions ansible/roles/ckan/templates/ckan.ini.j2
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ ckan.tracking_enabled = true

ckan.max_resource_size = {{ ckan_max_resource_size }}

ckan.upload.apply_permission.mimetypes = application/pdf image/png image/jpeg application/msword application/vnd.openxmlformats-officedocument.wordprocessingml.document application/vnd.ms-excel application/vnd.openxmlformats-officedocument.spreadsheetml.sheet application/vnd.ms-powerpoint application/vnd.openxmlformats-officedocument.presentationml.presentation application/vnd.oasis.opendocument.text application/vnd.oasis.opendocument.spreadsheet text/plain
ckan.upload.apply_permission.types = application image text


[loggers]

keys = root, ckan, ckanext
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/ckan/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ckan_patches:
- { file: "email_attachment" }
- { file: "fix_updating_resource_filesize" } # https://github.com/ckan/ckan/pull/7103
- { file: "fix_resource_delete_auth" } # https://github.com/ckan/ckan/pull/7132
- { file: "fix_detection_of_xlsx_mimetype"} # https://github.com/ckan/ckan/pull/8088

files_created_by_patches:
- { file: '/usr/lib/ckan/default/src/ckan/ckan/lib/csrf_token.py'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,11 @@ def settings_post(context, subsystem_id):
if (data_dict.get('delivery_method') == 'file' and data_dict.get('file_url', None)):
upload.update_data_dict(data_dict, 'file_url',
'file', 'clear_upload')
upload.upload(max_size=uploader.get_max_resource_size())

try:
upload.upload(max_size=uploader.get_max_resource_size())
except toolkit.ValidationError as e:
return settings_get(context, subsystem_id, e.error_dict, values=data_dict)

file_url = data_dict.get('file_url', '')
if re.match('https?:', file_url) is None:
Expand Down

0 comments on commit de60aa5

Please sign in to comment.