https://github.com/pyzh/tornado-file-upload-example
https://github.com/pyzh/tornado-file-upload-example
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/pyzh/tornado-file-upload-example
- Owner: pyzh
- Created: 2019-01-07T12:13:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2016-04-18T12:05:54.000Z (about 10 years ago)
- Last Synced: 2025-01-22T01:36:41.630Z (over 1 year ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
## 功能描述
启动服务端
mkdir upload
python3 server.py
浏览器中打开 (建议使用Firefox,因为只测试了Firefox)
http://127.0.0.1:8000/index.html
选择文件后会自动开始上传
两个进度条,第一个是已经上传成功的进度,第二个是浏览器提示的进度
上传成功后会显示文件链接
## 上传原理
浏览器发起PUT请求,每个请求只上传部分内容,用标准的Content-Range头来表示当前请求上传的范围。
## 服务端实现
所有文件相关操作都在线程池里运行。
打开文件时,若文件不存在,应该先创建。
若HTTP请求有Content-Range头,应该seek到其起始位置。
## 浏览器端实现
将文件按BLOCK_SIZE分块上传,若单块上传失败次数超过MAX_RETRY,即宣告上传失败。