V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
littlepython
V2EX  ›  Python

使用 flask 创建一个接口,别人上传文件,如何获取其中的文件

  •  
  •   littlepython · 2019-04-24 16:44:36 +08:00 · 2619 次点击
    这是一个创建于 1826 天前的主题,其中的信息可能已经有所发展或是发生改变。
    别人一次会 post 多张图片 但是我只想取 pictype=1 的图片,flask 中如何获取这部分参数,或者有什么方法可以过滤掉 pictype=0 的部分


    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
    Accept-Language: zh-cn
    Content-Type: multipart/form-data; boundary=---------------------------7daf10c20d06
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; CIBA; .NET CLR 2.0.50727)
    Host: 172.7.56.10
    Content-Length: 2740000
    Connection: close
    Cache-Control: no-cache

    -----------------------------7daf10c20d06
    Content-Disposition: form-data; name="userfile"; pictype=0&isurl=0&piclen=13000;filename="dev001_01_20110811155619_01_1.jpg"
    Content-Type: image/pjpeg

    <此处为图片数据或者 URL>
    -----------------------------7daf10c20d06
    Content-Disposition: form-data; name="userfile"; pictype=1&isurl=0&piclen=13000;filename="dev001_01_20110811155619_01_2.jpg"
    Content-Type: image/pjpeg

    <此处为图片数据或者 URL>
    2 条回复    2019-04-24 17:08:30 +08:00
    vZexc0m
        1
    vZexc0m  
       2019-04-24 17:01:25 +08:00   ❤️ 1
    ```
    request.files.get("dffff").headers["Content-Disposition"]
    ```
    littlepython
        2
    littlepython  
    OP
       2019-04-24 17:08:30 +08:00
    @vZexc0m 谢谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1121 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 22:42 · PVG 06:42 · LAX 15:42 · JFK 18:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.