批量上传文件夹和文件到gohttpserver

@echo off
rem recusive folders upload files from curl
setlocal enabledelayedexpansion
:start
set DIR=D:\Sharepoint - 03 Quality\Automation Test\TestData\Common+Preparation_HD3D
set oldStr=D:\Sharepoint - 03 Quality\Automation Test\TestData\Common+Preparation_HD3D
set replaceStr=http://10.196.98.73/Quality/TestData/Common+Preparation_HD3D

for /R "%DIR%" %%i in (*.*) do (
rem echo %%i
set name=%%i
set var=!name:%oldStr%=%replaceStr%!
rem replace \ to /
set var=!var:\=/!
rem replace space to %20
set var=!var: =%%20!
echo curl -g -F file=@"%%i" !var!
curl -g -F file=@"%%i" !var!
echo =========================
)
:e
rem ignore echo %name%|findstr /I "c1" && goto END rem goto start :END

解释:

因为本地文件名中可能会有空格,所以需要空格替换成%20。

windows机器上路径为\,所以要替换成/。

使用命令curl -g -F file=@文件名 远程文件夹 参考gohttpserver篇章Upload with CURL(GitHub - codeskyblue/gohttpserver: The best HTTP Static File Server, write with golang+vue)

使用curl下载文件的命令 curl -g -O 远程文件名

举例,curl -g -O http://localhost/TestData/Common_HD3D/common.HD3D.off%5B1.0.3.600%5D/Franklin_Benjamin_[2021-03-03_09-51-18].dcm

 

posted @ 2022-02-21 14:00  flying0dancing  阅读(443)  评论(0)    收藏  举报