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 小时前
3070文件格式--10--testorder文件格式详解
功能测试·测试工具·pcb工艺
想做后端的前端3 小时前
Redis中的Lua使用
数据库·redis·lua
weixin_395448914 小时前
draw_tensor2psd.py_cursor
lua·perl·symfony
我的xiaodoujiao4 小时前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 44--Pytest框架钩子函数
python·学习·测试工具·pytest
预立科技13 小时前
Redis 中 Lua 与 Pipeline 的相同点,区别,使用场景
redis·pipeline·lua
可可南木20 小时前
3070文件格式--9--boardxy文件格式详解 3
功能测试·测试工具·pcb工艺
最好有梦想~1 天前
Lua 学习笔记
笔记·学习·lua
安然无虞1 天前
「正则表达式」精讲
开发语言·测试工具·正则表达式
zbguolei1 天前
网络性能测试工具---iPerf
网络·测试工具
深蓝电商API1 天前
Selenium结合Chrome DevTools协议加速爬取
爬虫·python·selenium·测试工具·chrome devtools