IM 当路径在其中一个文件夹名称中有空格时,访问路径的 ->metadata 时出现问题。 因此,如果路径是/客户端/文件夹名称,则元数据调用返回 401。 我像这样对路径参数进行编码:
$path = str_replace('%2F', '/', rawurlencode($path));
这将为空格添加 %20。 如果我进入保管箱并将"文件夹名称"更改为"文件夹名称",一切都很好。 我应该有其他方法对路径进行编码吗?
下面是前面的更多代码我向下钻取到文件夹并将前面的文件夹路径作为查询字符串"路径"传递所以我有问题的网址是"/my-hub/?path=COMM%20POLICIES"
$clientpath = "/DACLIENTS/$username";//username is the current user
$path = $clientpath;
if(isset($_GET['path'])){
$path .= '/'.rawurldecode($_GET['path']);
}
$path = rawurlencode($path);
$path = str_replace('%2F', '/', $path);
// List contents of directory
if ($home = $client->metadata($path)) {
...
}
尝试使用原始空间。当我使用 Dropbox API 时,我从来不需要对空格进行编码。如果您查看元数据返回。带有空格的文件完全按原样编写,并且没有 urlencoding。
尝试类似
gsub("%2F","/",curlEscape($path)) <-- But this is rails.
从这里
这是php curl_escape
gsub 类似于这里
preg_replace( "/^('w[^'r'n]*)(?='r?'n'w.*$)/m", "''1 ", $text );
一种解决方案是编辑文件中的标题
问题来自发送的文件标头中的文件名格式/编码。解决方法是 rawurldecode 标头中的文件名。
https://code.google.com/p/dropbox-php/issues/detail?id=13
PS - 路径名存储为字节
https://code.google.com/p/dropbox-php/issues/detail?id=10