web.py multipart file handling
来源:互联网 发布:淘宝限制购买数量 编辑:程序博客网 时间:2024/05/21 17:43
I'll have to admit that... it was so easy to use $_FILE for file uploading in PHP.
Trying to switch to Python from PHP (for various reasons including shared configuration between web and background processes, etc). Started looking at web.py (with other alternatives as well) and, surprisingly, found that the webpy's document is nothing more than... nothing. Even the "receipts" in "cookbook" are for those who don't need them. So I'm lost totally just in handling uploaded file.
Task: to handle a file upload.
Solution:
def POST(self): x = web.input('log', log={})
Trick here is the log={} part. Without it, x.log would be a string containing the whole content of the file. This is a completely undocumented behavior. If you need something more familiar, specify the "log={}" part, and you'll get x.log.filename for remote filename and x.log.file for a file object to access it. I still haven't figured out how to directly operate on the uploaded file (or python didn't do this part at all?) but at least I got a file object to deal with.
Related code:
https://github.com/webpy/webpy/blob/master/web/utils.py#L160
If the key is not in the "defaults" , or the specified defaults value isn't a dict, value is inflated before added to the Storage object.
- web.py multipart file handling
- File Handling
- java.io.File 转 org.springframework.web.multipart.MultipartFile
- Basic distinguish between web.py / flup and tornado web process handling model (TBC)
- ios file handling
- file handling in python
- web.py (url.py)
- python multipart 类型 和 后台运行py
- web.py
- web.py
- web.py
- web.py
- Golang Multipart File Upload Example
- spring mvc multipart file upload
- SAP message log file handling
- linux File-Handling System Calls
- Ajax File Upload Response Handling
- py copy file
- mysql和postgreSQL数据库各种版本的源代码下载地址
- PYTHON学习之初识PYTHON
- uva 297 Quadtrees
- hdu2433 Travel
- 敏捷开发流程
- web.py multipart file handling
- 性能测试工具三(ArcGIS Performance calibration tool)
- 用Firefox进行Web开发
- UIButton 样式
- 性能测试工具二(数据库性能分析与诊断工具 tell the bees)
- 一个30年老程序员的回顾(五)
- 性能测试工具一(mxd性能测试工具(mxdpefstat))
- 2012-11-07记事
- Liferay auto.login.hooks developed by using hook and ext plugins