我想这很简单,但我不知道该怎么做。我想使用 AFNetworking 库将文件上传到使用 PUT 请求的网络服务。这是我用来测试服务的 curl 命令
mac:~ user$ curl --verbose -T image.jpeg http://server.org:8001/social/test.jpg
* About to connect() to server.org port 8001 (#0)
* Trying 123.45.123.123...
* connected
* Connected to server.org (123.45.123.123) port 8001 (#0)
> PUT /social/test.jpg HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: server.org:8001
> Accept: */*
> Content-Length: 78341
> Expect: 100-continue
>
< HTTP/1.1 100 CONTINUE
< Server: cx1193719-b
< Content-Type: Text/Html
< Accept-Ranges: bytes
< Content-Length: 0
* We are completely uploaded and fine
< HTTP/1.1 200 OK
< Server: cx1193719-b
< Content-Type: Text/Html
< Accept-Ranges: bytes
< Content-Length: 0
<
* Connection #0 to host server.org left intact
* Closing connection #0
我已经能够使用 POST 和表单数据将文件上传到其他 Web 服务,我使用了 PUT 请求(使用 AFHTTPClient 和 putPath),但我仍然不明白如何进行简单的文件上传。
谢谢你的帮助!