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

相关推荐
天才测试猿3 小时前
2026全新软件测试面试八股文【含答案+文档】
自动化测试·软件测试·python·功能测试·测试工具·面试·职场和发展
每天回答3个问题4 小时前
Lua 字符串
ue4·lua
奋进的电子工程师9 小时前
新架构下高精度时间戳总线接口卡 TestBase VCI 0620
测试工具·fpga开发·软件工程
线束线缆组件品替网10 小时前
Aries Electronics 定制线缆选型与设计建议
数码相机·测试工具·智能手机·电脑·pcb工艺
may_一一11 小时前
selenium自动化调用接口为null问题处理
selenium·测试工具·自动化
JTnnnnn1 天前
【疑難排解】解決 Postman 無法上傳本地文件(Couldn‘t upload file)的問題
测试工具·postman
Minecraft红客1 天前
ai_dialogue_framework项目1.0(纯原创)
c++·测试工具·电脑
Wang's Blog1 天前
Lua: 基于协程的生产者-消费者模型实现
开发语言·lua
Wang's Blog1 天前
Lua: 协程编程详解之从基础到多任务处理与应用实战
开发语言·lua
就叫飞六吧1 天前
wrk:现代 HTTP 性能测试工具(类cc)
网络协议·测试工具·http