我已经搜索过,但没有发现任何可以解决我遇到的问题的内容。如果我错过了这个,我很抱歉。
使用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主机运行的。
任何帮助或指导将不胜感激
韩国社交协会
答案 0 :(得分: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