Closed jannesjust closed 7 months ago
@fschrempf do I remember correctly that this was your part of the code? Do you have time to look into this bug report?
@fschrempf do I remember correctly that this was your part of the code? Do you have time to look into this bug report?
No, I never used or touched file_upload()
so far.
@jannesjust - i could not reproduce your described behavior.
Not only do we already have songs like "Macht hoch die Tür" on our system, i did also add a test case which specifically checks a test file with Umlaut.
Are you sure you're using the song_arrangement_id and not the song_id to upload you attachment? I've updated a docstring to strongly point out this difference ... https://github.com/bensteUEM/ChurchToolsAPI/commit/53c0de025219be4f019f789b0ab2880ac0420d53#diff-026cdb0bee0effb8f5d2b4e8d06983b2fbab48b868670644ea2d0e12ce8c153cR28
If this wasn't the cause i'd need more information.
Thanks for your quick testing and reply.
Yes I am using the song_arrangement_id and not the song id. I have a folder containg around 150 files. All of them are uploaded correctly, but files with umlauts or special characters do not upload.
The first failed filename was "011. Man erzählte mir froh". It is a pdf file. I've also tried to use the custom_file_name and upload the file with a different name, it works, but I would not like to change the file name.
I've tried your mentioned filename and that does not upload neither.
We are on ChurchTools v3.103.0
That's my code:
def initial_file_upload(api, category):
cwd = os.getcwd()
os.chdir(cwd +"/Lieder/3.Chor")
songs = api.get_songs()
for song in songs:
if song['category']['id'] == category:
name = f'{song["name"]}.pdf'
arrangement = song['arrangements'][0]['id']
if api.file_upload(name, 'song_arrangement', arrangement, overwrite = True) == True:
logging.info(name + " hochgeladen")
else:
logging.info(name + " fehlgeschlagen")
time.sleep(1)
I'd rather suspect the use of you . might be a problem. I'll have to look into the code again though...
If that's not the issue
what OS are you running on (I suppose Windows? I'm testing on Linux...
what's the filesize?
does the file upload using the regular swagger API?
[x] check if . In filename might cause issues
[x] check if pdf is still allowed
[x] check maximum filesize
One more idea ... my test runs with overwrite = False as default. Can you try to upload without overwrite and let me know if the issue persists?
Yes I am using Windows.
Filesize is around 1 MByte. I can upload the exact same file using the custom_file_name attribute. That means, that the file is available on my computer and can be read
The . in the filename does not cause problems. Every filename I was uploading had . in it
First I also tried it without the overwrite option, that also did not work
When I upload the file via the webbroser in ChurchTools by hand, it works and the Umlaut is showing correctly
After some testing on other machines and updating everything, I found the issue. Previously I used Python version 3.7.4 which did not work. After updating to 3.12.0 it finally works. Thanks for your support.
Thanks for the update. Would you mind trying again with Python 3.8 as specified in the requirements?
[tool.poetry.dependencies]
python = "^3.8"
If it does work with 3.8 i'd keep everything as is, but if you require 3.9, 3.10 or newer I'd have to update the requirements :) It looks like my venv is currently using 3.11 ...
Yes, it also works with 3.8
If there are umlauts in the file name, I get the answer 200 back, but the file is not uploaded.