2017-07-27 50 views
0

我想了解如何通过使用Guzzle将远程WebDAV服务器上的文件复制到同一台服务器上的另一个位置。我现在有如何在WebDAV中使用Guzzle复制远程文件?

$client->request('COPY', 'file1.txt', [ 
    'Destination' => 'file2.txt', 
    'Overwrite' => 'T', 
]); 

这种方法是给我400响应

Client error: 'COPY http://example.com/remote.php/dav/files/admin/file1.txt' resulted in a '400 Bad Request' response: 

FILE1.TXT确实存在,它不是一个权限问题。

我正在关注一些文档*并试图猜测我的工作方式,因为我在网上找不到任何示例。

任何人都可以让我知道我需要改变什么吗?

*如https://docs.nextcloud.com/server/12/developer_manual/client_apis/WebDAV/index.html

回答

0

我找到了答案。 Destination和Overwrite参数需要在标题中发送。

$headers = [ 
    'Destination' => 'file2.txt', 
    'Overwrite' => 'T', 
]); 
$client->request('COPY', 'file1.txt', [ 
    'headers' => $headers, 
]); 

似乎有一个真正缺乏关于WebDAV的文档。