我正在尝试使用他们的 Api(https://www.file.io/#one,见下文)在 Excel 中使用 VBA上传https://file.io文件。
我发现这个线程如何将文件上传到 file.io 并获取链接,但是,我不知道如何准确地将它从 C# 传输到 VBA。
File.io 上的语法是:
$ curl -F "file=@test.txt" https://file.io
{"success":true,"key":"2ojE41","link":"https://file.io/2ojE41","expiry":"14 days"}
$ curl https://file.io/2ojE41
This is a test
$ curl https://file.io/2ojE41
{"success":false,"error":404,"message":"Not Found"}
Run Code Online (Sandbox Code Playgroud)
我当前的代码如下所示:
Set objhttp = CreateObject("MSXML2.ServerXMLHTTP")
URL = "https://file.io"
objhttp.Open "post", URL, False
objhttp.setRequestHeader "Content-type", "application/json"
objhttp.Send ("file=@C:/Users/me/Downloads/image.jpg")
Debug.Print objhttp.responsetext
Run Code Online (Sandbox Code Playgroud)
我的响应文本说:
{"success":false,"error":400,"message":"Trouble uploading file"}
Run Code Online (Sandbox Code Playgroud)
我什至不确定路径中的“@”或者是否通常使用标准文件夹等。提前非常感谢!感谢所有帮助。