understanding file renaming within flask_uploads. (any filename changes other than " " replaced by "_" ? )

104 Views Asked by At

I'm using flask_uploads within a python virtual environment where Flask-Reuploaded is installed. (I mention this as I've noticed a few versions of flask_uploads and have no idea how these differ)

from flask_uploads import configure_uploads, ALL, UploadSet
all = UploadSet('all', ALL)
configure_uploads(app, all)

then in a flask route

form = MyForm()
    if form.validate_on_submit():
        filename = form.all.data.filename
        fname = all.save(form.all.data)

filename and fname will not always be the same. fname appears to replace any spaces in filename with "_". if duplicate filenames are uploaded, fname appears to append "_01", "_02" etc to the filename uploaded.

just wanted to check I'm interpreting the observed behaviour correctly as I couldn't find the relevant source code.

caveat : while I've checked the installed packages within the virtual env I'm using, I was a bit thrown by pip freeze not showing 'flask_uploads' as an installed package. It's remotely possible my 'import flask_uploads' is pulling flask_uploads from somewhere else (?)

for reference, the virtual environment I'm using

pip freeze 
.....
click==8.1.3
colorama==0.4.5
Flask==2.1.2
Flask-Reuploaded==1.2.0
Flask-WTF==1.0.1
importlib-metadata==4.12.0
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.1
Werkzeug==2.1.2
WTForms==3.0.1
zipp==3.8.0

idk if many ppl aren using Flask-Reuploaded, the volume of tutorials, demos and questions seems small. (hopefully I'm wrong)

1

There are 1 best solutions below

0
On

package owner answered the question in github issues. https://github.com/jugmac00/flask-reuploaded/issues/131