Comments (9)
EDITED
flask-autoindex/flask_autoindex/__init__.py
Line 148 in 4242462
flask-autoindex/flask_autoindex/__init__.py
Line 150 in 4242462
def send_file(..., as_attachment: bool = False)
I think adding this one argument as_attachment=True
(TRUE) should solve this.
from flask-autoindex.
Hello! any news about this issue? if there any workaround will be appreciated
from flask-autoindex.
Hello,
I can't reproduce issue, in my computer I download files successfully.
You can configure your browser to force download file
from flask-autoindex.
Here is the full code if you want to test it. Added some attachments.
import pathlib
from flask import Blueprint, Flask, send_file
from flask_autoindex import AutoIndexBlueprint
app = Flask(__name__)
foo_dir = pathlib.Path(r'C:\foo')
bp_ai = Blueprint('foo', __name__, static_folder='./static', template_folder='templates')
AutoIndexBlueprint(bp_ai, browse_root=f'{foo_dir.absolute()}', template_context=dict(x='y'))
app.register_blueprint(bp_ai, url_prefix='/ai')
sample_mp4_file_path = foo_dir / 'sample-mp4-file.mp4'
@app.route("/browser_ok_mp4_as_attachment_true")
def x():
return send_file(f'{sample_mp4_file_path.absolute()}', as_attachment=True)
@app.route("/browser_ok_mp4_as_attachment_false")
def y():
return send_file(f'{sample_mp4_file_path.absolute()}', as_attachment=False)
if __name__ == '__main__':
app.run()
Test video is from here
As you can see its not browser issue. Browser will download file instead of opening if provided as_attachment=True in send_file. I found no way to provide this parameter in AutoIndex.
from flask-autoindex.
The as_attachment=True
parameter allow to add Content-Disposition
header to attachment
so to download file as fai can do.
I think your issue title do not reflect that you want !
Your browser treat the header to do something : https://stackoverflow.com/a/1395173/2641416
from flask-autoindex.
Oh... I See. Thanks.
Instead of opening a new issue or editing the title, I am just requesting here the feature request.
Please add an option to pass as_attachment=True
parameter or something similar to AutoIndex, for adding Content-Disposition header to attachment.
Ex. During init, AutoIndexBlueprint(..., as_attachment=True)
or,
Or, in config, AUTOINDEX_AS_ATTACHMENT = True
from flask-autoindex.
Your request is to configure globally the path to download all files inside ?
from flask-autoindex.
Your request is to configure globally the path to download all files inside ?
Sorry, I don't understand the part "download all files inside".
Current Situation:
-> Clicking on a file, it load directly inside the browser.
Wanted Situation:
-> Clicking on a file, ask me save or download it.
How:
Enable Attachment mode by taking advantage of "as_attachment
" parameter of send_file
function. Which will add Content-Disposition
header to attachment
in file.
Request:
Please Give us an option to "Enable Attachment mode".
So, request is to configure globally the path to add Content-Disposition
header to attachment
for all file inside ?
from flask-autoindex.
hey guys
i have the same issue
i'm using this example: #16 (comment)
so
how can i disable this web preview and force download using this way as example?
from flask-autoindex.
Related Issues (20)
- Sort order parameter is not validated HOT 1
- New maintainer HOT 4
- Dark Theme for app HOT 1
- python3: ModuleNotFoundError: No module named 'flask.ext' HOT 4
- Is it possible to set action for specific file extension? HOT 2
- Running Autoindex in Docker HOT 4
- Flask-login for every paths HOT 2
- Flask-Autoindex 0.6.4 does not work with Werkzeug 1.0.0 HOT 1
- Please fix licensing ambiguation HOT 1
- How to set mimetype based on file extension HOT 1
- render_autoindex('.') not working in 0.6.6 HOT 2
- Hide files HOT 1
- file autoindex multiple downloads issue HOT 2
- Redirect errors
- Autoindex send file images as attachment HOT 2
- ps
- UnicodeEncodeError when special characters in folder/file names
- Render file content
- unitest test_own_page fails with Flask 2.2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask-autoindex.