无法将多个带有curl的文件发送到send-anywhere.com

其秘密

我试图在Crystal中构建CLI工具以send-anywhere.com从命令行使用

发送分段不是Crystal内置的,但是在编写自己的文件之前,我想我会尝试使用cURL来查看我应该如何做,但是我什至无法使它与cURL一起使用!

问题是,当使用cURL发送多个文件时,他们的服务器仅看到1个文件传入,他们确实看到了总长度,但由于只希望一个文件,因此失败了50%。

使我丧命的是它可以在浏览器中运行,我打开了网络检查器,但看不到cURL请求的区别。我尝试将Expect标头设置为100-continue,对它们进行了比较,但是我看不到有什么可以使它与浏览器一起工作而不卷曲。

这是我使用cURL尝试的所有命令,结果相同,服务器最终只看到1个文件传入,而不是2个。

为了进行测试,我使用了一些通用许可文件的副本。

curl -F file1=@LICENSE -F file2=@LICENSE1 https://...their.weblink...

我在检查器中看到Chrome在Content-Disposition中命名为文件名=“ file []”,所以我自己尝试了一下(结果相同):

curl -F file[]=@LICENSE -F file[]=@LICENSE1 https://...their.weblink...

我也尝试了使用-H "Expect: 100-continue"相同结果的这两个命令

在这一点上,我发了疯,以为自己会自己尝试,也许cURL不能正确执行(非常不可能的imo,我做错事的可能性更大)。

因此,在从头开始编写之前,我尝试了Telegram机器人使用的实现,请参见此处:https : //github.com/hangyas/TelegramBot/blob/b3fcbbb621bd669bbafe9f3e91364702d06d1e10/src/TelegramBot/http_client_multipart.cr

这很简单,但是我仍然遇到同样的问题。仅第一个文件被识别。

注意:当仅发送一个文件时,一切都可以与cURL和Crystal实现一起使用。

我快疯了,可以正常使用的浏览器与其他两个浏览器有什么区别?我没看到什么?

我不是在寻找实现,而是只是为了指出某人我错过的东西,这将使多个文件被正确识别?

琼恩(Jonne)仇恨

这仅出于教育目的,实际上这样做违反了服务条款。给定一个API密钥后,它具有文档化的API,您应该改用它。

key正确端点声明文件数量很重要因此,整个流程如下所示:

#!/bin/bash

# First we need to get a device key by registering ourselves as a
# device. For that we need a profile name. We need to store the
# received cookie and send it with the subsequent request.
profilename="$(openssl rand -hex 6)"
curl -c .session -vL https://send-anywhere.com/web/device \
  -d "os_type=web" \
  -d "profile_name=$profilename" \
  -d "manufacturer=Linux" \
  -d "model_number=Firefox" \
  -d "app_version=48" \
  -d "device_language=en-US"

# We need to know the individual filesizes in bytes as well as
# the total size we're going to upload
file0name="foo.txt"
file0size="$(wc -c "$file0name" | cut -d ' ' -f 1)"
file1name="bar.txt"
file1size="$(wc -c "$file1name" | cut -d ' ' -f 1)"
filesize="$(echo "$file0size + $file1size" | bc)"

# Using that info and the cookie we got from the device key
# we can correctly announce our upload
key="$(curl -b .session -vL https://send-anywhere.com/web/key \
  -d "file[0][name]=$file0name" -d "file[0][size]=$file0size" \
  -d "file[1][name]=$file1name" -d "file[1][size]=$file1size" \
  -d "file_number=2" -d "file_size=$filesize")"

# We get some JSON back with the URL to send to the receiver
# and the URL to upload back
url="$(echo "$key" | ruby -rjson -e 'print JSON.parse($stdin.read)["link"]')"
upload_url="$(echo "$key" | ruby -rjson -e 'print JSON.parse($stdin.read)["weblink"]')"

echo
echo "------------------------------------------------------------"
echo "Receive 2 files of $filesize bytes at $url"
echo "------------------------------------------------------------"
echo

# And finally do the upload
curl -vL "$upload_url" \
  -F "file[]=@$file0name" \
  -F "file[]=@$file1name"

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何使用JAVA将数据发送到COM PORT?

无法将带有Ajax的文件发送到php文件

无法在Python Anywhere上部署Django应用程序:ImportError:没有名为“ environ”的模块

无法使用curl将大文件发送到elasticsearch:参数太长

cors-anywhere.herokuapp.com无法正常运行(503)。我还能尝试什么?

使用带有ajax的post请求将html表单数据发送到php到https://foo.com

将cURL数据发送到多个URL

使用Curl和PHP将文件发送到Anonfile

PHPMailer发送到office.com中的垃圾文件夹

Sybase SQL Anywhere的Row_Number在多个条件下发生更改

无法将文件发送到后端

搜寻Anywhere + Solr + Tomcat:无法访问搜寻器管理

Python-将行发送到多个设备(在带有IP的文本文件中列出)

Kmail无法发送到smtp.office365.com

在app.xml中添加新的VIEW后无法登录Maximo Anywhere(工作执行应用)

通过蓝牙将数据从android应用发送到串行COM端口

如何使用带有TCPDF的php将文件内联发送到浏览器

发出将POST数据发送到带有字符“ñ”的登录表单的问题(使用Curl Works)

通过带有cURL的HTTP Post将XML字符串发送到Web服务

无法将多个文件从JQuery AJAX发送到ASP.NET MVC

将带有GNU邮件的附件发送到@ kindle.com

将SQL Anywhere设置为不自动交叉联接

NetworkManager是否将HTTP请求发送到googleusercontent.com?

使用Java将变量发送到ubuntu上的Arduino COM端口

如何通过 api 将本地图像文件发送到 parse.com?

无法在 Automation Anywhere 10 中使用 Excel 作为数据库

如何使用 Automation Anywhere 遍历 Web 表格列并下载多个 PDF 文件?

如何在运行时(动态)在 Automation Anywhere 中将多个值存储在变量中?

带有 Cors-Anywhere 的 jQuery Recaptcha v2 缺失输入响应