You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Linux下用curl上传CSV到QuestDB,求Windows PowerShell等效命令

解决QuestDB CSV上传的PowerShell等效命令

你的问题出在未以multipart/form-data格式发送请求——Linux下的curl -F会自动使用这种格式,但你之前的Invoke-RestMethod命令默认用的是其他编码,导致QuestDB接口拒绝。以下是两种可行的等效方案:

方案1:使用Invoke-WebRequest(PowerShell原生方式)

利用-Form参数自动构造multipart/form-data请求,和curl -F行为完全一致:

# 单命令写法
Invoke-WebRequest -Uri "http://localhost:9000/imp?name=AllTrade" -Method Post -Form @{ data = Get-Item "C:\path\to\AllTrades.csv" }

# 拆分写法(更清晰)
$csvFile = Get-Item "C:\path\to\AllTrades.csv"
Invoke-WebRequest -Uri "http://localhost:9000/imp?name=AllTrade" -Method Post -Form @{ data = $csvFile }

方案2:直接用Windows自带的curl.exe

Windows 10及以上系统预装了原生curl.exe,可以直接复用Linux下的语法(仅需调整路径写法):

curl.exe -F data=@"C:\path\to\AllTrades.csv" http://localhost:9000/imp?name=AllTrade

注意必须写curl.exe,避免和PowerShell中Invoke-WebRequest的别名curl混淆。

两种方案都能正确将CSV文件以表单字段data的形式上传到QuestDB的/imp接口,匹配你原来的Linux curl命令逻辑。

内容的提问来源于stack exchange,提问作者Alex des Pelagos

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 21:57:19