Skip to content

Commit

Permalink
Merge pull request #213 from ckan/fix_file_uploads_on_localckan
Browse files Browse the repository at this point in the history
Fix file uploads on localckan
  • Loading branch information
wardi authored Mar 12, 2024
2 parents 963f927 + 83468a3 commit 806ec26
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
test:
strategy:
matrix:
python-version: ["2.7", "3.8"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
runs-on: ubuntu-latest
container:
# INFO: python 2 is no longer supported in
Expand Down
12 changes: 7 additions & 5 deletions ckanapi/localckan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from cgi import FieldStorage
from tempfile import TemporaryFile

from ckanapi.errors import CKANAPIError
Expand Down Expand Up @@ -64,10 +63,13 @@ def call_action(self, action, data_dict=None, context=None, apikey=None,
except (AttributeError, IOError):
f = _write_temp_file(f)
to_close.append(f)
field_storage = FieldStorage()
field_storage.file = f
field_storage.filename = filename
data_dict[fieldname] = field_storage

from werkzeug.datastructures import FileStorage

file_storage = FileStorage()
file_storage.stream = f
file_storage.filename = filename
data_dict[fieldname] = file_storage

return self._get_action(action)(context, data_dict)
finally:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
'simplejson',
]
tests_require=[
'pyfakefs==3.6.1',
'pyfakefs==5.3.5',
]


Expand Down

0 comments on commit 806ec26

Please sign in to comment.