fetch使用put请求提交文件,postman使用put请求提交文件

javascript 复制代码
import { createFetch } from "@vueuse/core";
       


         // 上传
        const useMyFetch = createFetch({
          options: {
            async beforeFetch({ options }) {
              options.method = "PUT";
              options.headers = {
                ...options.headers,
                "Content-Type": req.file.type
              };
              return { options };
            }
          }
        });
        const { error } = await useMyFetch(host).put(req.file).text();

        if (error.value) {
          ElMessage.error("文件上传失败");
          item.error = error.value.message;
          emit("error", item);
          return reject(error);
        }

人工智能学习网站

https://chat.xutongbao.top

相关推荐
though the night4 小时前
Python UI 自动化测试框架搭建demo(Selenium+Pytest 版)
自动化测试·selenium·测试工具·pytest
Wpa.wk5 小时前
Docker原理和使用场景(网络模式和分布式UI自动化环境部署)
linux·经验分享·分布式·测试工具·docker·性能监控
假女吖☌5 小时前
Lua 脚本
开发语言·lua
我送炭你添花5 小时前
软件测试为何不可或缺?——以复杂宏系统与 PTZ 控制为例,深度解析 pytest 的实战价值与不可替代性
python·测试工具·pytest
今天多喝热水5 小时前
Lua脚本实现滑动窗口
java·开发语言·lua
我的xiaodoujiao21 小时前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 43--添加allure测试报告显示信息和其他封装方法
python·学习·测试工具·allure
晚霞的不甘1 天前
Flutter for OpenHarmony 创意实战:打造一款炫酷的“太空舱”倒计时应用
开发语言·前端·flutter·正则表达式·前端框架·postman
可可南木1 天前
3070文件格式--10--testorder文件格式详解
功能测试·测试工具·pcb工艺
想做后端的前端1 天前
Redis中的Lua使用
数据库·redis·lua