2017-07-27 64 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的文檔。