How to make a direct download link to a static file
2010-08-17 12:41
507 查看
I want to make a link to allow user to download the static file.
with open(path, 'rb') as f: response = HttpResponse(f.read()) response['Content-Type'] = 'application/octet-stream'; response['Content-Disposition'] = 'attachment; filename="%s"' % 'insert_filename_here' return response[/code]
相关文章推荐
- How to make Universal Static library (.a file) in iOs using xCode
- a survey about how to make a file dynamically and offer it to download,but still not save the file!
- How to download a file
- How to download Android SDK files via bat file (curl)
- how to make a JAR file
- Android Studio下NDK开发之"No such file or direct"和“no rule to make target”
- How to make seperate debuginfo file
- How to write make file?
- How to download Xcode 4 / 5 / 6 / 7 and get the DMG file?
- c# how to make app use a specified configure file
- how to make a authorware file in an environment without authorware
- How to make a USB stick use ISO image file in debian
- how to compile and link static/dynamic library in linux
- How to unlock xcode file to make edits from different computers?
- How to load Properties file from a static block or static method
- How to download your ABAP Codes into PDF file?
- How to make a submit out of a <a href…>…</a> link?
- How to Make an Exe File
- How to download a file with Node.js?
- how to make&get trace file