Rest 如何使用curl加速/并行处理POST/PUT请求?
这是我得到的情况。我需要检查租户的配置是否通过API。根据检查结果,我确定配置是否遗漏了某些zip文件,然后上传遗漏的那些文件 简化代码如下所示。省略了创建最终租户列表的逻辑,但它确实创建了正确的结果-对于Rest 如何使用curl加速/并行处理POST/PUT请求?,rest,http,curl,file-upload,Rest,Http,Curl,File Upload,这是我得到的情况。我需要检查租户的配置是否通过API。根据检查结果,我确定配置是否遗漏了某些zip文件,然后上传遗漏的那些文件 简化代码如下所示。省略了创建最终租户列表的逻辑,但它确实创建了正确的结果-对于check\u config\u list中的每个文件,逻辑检查租户是否缺少该文件,如果是,则上载该特定文件 # List of files to be uploaded check_config_list="file1.zip file2.zip file3.zip"
check\u config\u list
中的每个文件,逻辑检查租户是否缺少该文件,如果是,则上载该特定文件
# List of files to be uploaded
check_config_list="file1.zip file2.zip file3.zip"
for i in $check_config_list; do
# A logic which creates a list of tenants missing the current file from the list
for tenant in $result; do
curl -s \
--location \
--request POST "https://www.example.com?tenant=$tenant" \
-H "accept: application/json; charset=utf-8" \
-H "Content-Type: multipart/form-data" \
--header "Authorization: Bearer ${token_here}" \
-F "file=@$i.zip;type=application/zip"
done
done
问题是-如何加快这一过程
由于check_config_list
中有10个文件和450个租户,浏览这两个列表需要2小时以上的时间
我已经厌倦了使用以下选项:
-F "file=@file1.zip;type=application/zip" -F "file=@$file2.zip;type=application/zip"
-F "file1=@file1.zip;type=application/zip" -F "file2=@$file2.zip;type=application/zip"
-F "file[]=@file1.zip;type=application/zip" -F "file[]=@$file2.zip;type=application/zip"
-F "file=@file1.zip,file2;type=application/zip"
结果是一样的——我得到了HTTP/500消息作为回报