像postman上传文件_由postman批量上传文件并接收

def del_file(filepath):
    """
    删除某一目录下的所有文件或文件夹
    :param filepath: 路径
    :return:
    """
    del_list = os.listdir(filepath)
    for f in del_list:
        file_path = os.path.join(filepath, f)
        if os.path.isfile(file_path):
            os.remove(file_path)
        elif os.path.isdir(file_path):
            shutil.rmtree(file_path)

def fusion_multiple_mode_text_create_graph():
    # basepath获取项目目录下文件保存地址
    basepath = os.path.join(BASE_DIR, "../../data/Map_Data")
    # 在postman中上传时需要填写key值
    upload_files = request.files.getlist('text_data')  # postman中 KEY
    # 保存postman批量上传文档到本地、写盘操作
    file_path = os.path.join(basepath, "fusion_multiple_modes_data","text_data")
    del_file(file_path)
    for file in upload_files:
        filename = secure_filename(file.filename)
        upload_path = os.path.join(file_path, filename)
        file.save(upload_path)

9510d7c3d8be4fd57362fb7d2311071d.png

参考文献:http://einverne.github.io/post/2017/07/flask-upload-files.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值