0

我已经搜索并没有找到任何可以回答我遇到的问题的东西。如果我错过了这一点,我深表歉意。

使用 curl,我一直在尝试将一个小图像文件上传到现有的 Box 文件夹,但没有成功。它不会返回我可以调试的错误消息。我使用的 folder_id 是有效的,我可以使用相关的 API 调用列出它的内容。

下面是 POST 请求的详细结果。如果有人能阐明我哪里出错了,我将不胜感激

curl -k -v https://www.box.com/api/2.0/files/content/ -H "Authorization: BoxAuth api_key=API_KEY&auth_token=AUTH_TOKEN" -F filename="c:\alarms.gif" -F folder_id=FOLDER_ID

* About to connect() to www.box.com port 443 (#0)
*   Trying 74.112.184.70...
* connected
* Connected to www.box.com (74.112.184.70) port 443 (#0)
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using RC4-SHA
* Server certificate:
*        subject: serialNumber=ts5jamwzcjWP0oTyh2m74yh0zsB2zyOR; C=US; ST=California; L=Palo    Alto; O=Box.net, Inc.; CN=*.box.com
*        start date: 2011-09
*        expire date: 2013-09
*        subjectAltName: www.box.com matched
*        issuer: C=US; O
*        SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
> POST /api/2.0/files/content/ HTTP/1.1
> User-Agent: curl/7.28.0
> Host: www.box.com
> Accept: */*
> Authorization: BoxAuth api_key=API_KEY&auth_token=AUTH_TOKEN
> Content-Length: 263
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=----------------------------704f2d9b4096
>
* Done waiting for 100-continue
< HTTP/1.1 100 Continue
< HTTP/1.1 200 OK
< Server: nginx
< Date: Tue, 20 Nov 2012 08:14:13 GMT
< Content-Type: application/json
< Connection: keep-alive
< Cache-control: private
< Content-Length: 30
<
{"total_count":0,"entries":[]}* Connection #0 to host www.box.com left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):

源文件 c:\alarms.gif 是有效文件并且存在。这是从 Windows 主机运行的。

任何帮助或指导将不胜感激

Tks

4

1 回答 1

1

使用 cURL 上传本地文件时,需要@在文件路径前添加符号;这告诉 cURL 在该路径上传文件,而不是仅仅读取字符串。在您的情况下,您想要:

curl -k -v https://www.box.com/api/2.0/files/content/ -H "Authorization: BoxAuth api_key=API_KEY&auth_token=AUTH_TOKEN" -F filename=@"c:\alarms.gif" -F folder_id=FOLDER_ID
于 2012-11-20T23:47:10.733 回答