我无法将文件上传到CoreApI中的iOS中的Dropbox
我收到此消息
[警告] DropboxSDK:发出错误请求 /1/files_put/sandboxsandbox/helloworld.txt - (400)预期'root'到 是'dropbox','sandbox'或'auto',得到了你的盒子和盒子'2013-12-04 18:23:57.348 DropBoxCore [4914:907]文件上传失败,错误 - 错误域= dropbox.com代码= 400“操作不能 完成。 (dropbox.com错误400.)“UserInfo = 0x22b1d7f0 {SOURCEPATH =的/ var /移动/应用/ 28B2865A-58BC-4DC8-8E61-7F40307DDC56 / DropBoxCore.app / helloworld.txt, destinationPath = sandbox / helloworld.txt,error =预期的'root'为 'dropbox','sandbox'或'auto',得到了你的andboxsandbox'}
有人可以帮助我,我已经搜索了这个,但找不到任何解决这个问题的方法。
答案 0 :(得分:2)
来自Dropbox docs for file_put:
网址结构
https://api-content.dropbox.com/1/files_put/<root>/<path>?param=val
root 指定路径的根目录。有效值为 sandbox 和 dropbox 。
路径您要检索的文件的路径。
错误消息中的一小部分信息是请求中URI的路径部分。您的错误消息中的相关行:
error making request to /1/files_put/sandboxsandbox/helloworld.txt
与文档中的网址结构相比,<root>
您已使用sandboxsandbox
,但文档仅说明sandbox
和dropbox
是有效值。
JSON响应正文中的错误有类似的线索:
error=Expected 'root' to be 'dropbox', 'sandbox', or 'auto', got u'sandboxsandbox'
参考API文档是不必要的,因为错误消息指出sandboxsandbox
不在 root 的有效值列表中。
虽然稍微不那么明显,但与URL结构和文档相比,JSON中的这一位给出了一个提示:
destinationPath=sandbox/helloworld.txt
在 destinationPath 与API文档中的路径对应的小小的飞跃之后,读取 root 是&#34;根相对于指定了哪条路径&#34;你可以猜测路径不应该包含根。通过查看网址结构已经在/helloworld.txt
和helloworld.txt
之间考虑/
,可以推断出它应该是<root>
还是<path>
。分别使用/helloworld.txt
和helloworld.txt
比较这些扩展:
/1/files_put/<root>/<path>
/1/files_put/sandbox/<path>
/1/files_put/sandbox//helloworld.txt
/1/files_put/<root>/<path>
/1/files_put/sandbox/<path>
/1/files_put/sandbox/helloworld.txt
应该清楚 path 的哪个值是正确的。
答案 1 :(得分:0)
如果您共享代码会有所帮助,但我的猜测是您传递的路径如sandbox/helloworld.txt
,而应该传递/helloworld.txt
。如果不是这样,请分享您的代码。