2017-03-08 63 views
1

我想(PHP)捲曲使用S3流包裝(s3://...)和獲取跟隨誤差從Amazon S3 PUT文件到Vimeo有沒有辦法捲起一個遠程文件?這是捲曲選擇採用發送:PHP CURL PUT(TCP流)

$curl_opts = array(
    CURLOPT_PUT => true, 
    CURLOPT_INFILE => $file, // this refers to 's3://path-to-object' 
    CURLOPT_INFILESIZE => $size, 
    CURLOPT_UPLOAD => true, 
    CURLOPT_HTTPHEADER => array('Expect: ', 'Content-Range: replaced...') 
); 

回答

1

把它之前將文件保存到本地服務器:

$file = tempnam(sys_get_temp_dir(), "foo"); 
$data = file_get_contents("s3://path-to-object"); 
$size = strlen($data); 
file_put_contents($file, $data); 
$curl_opts = array(
    CURLOPT_PUT => true, 
    CURLOPT_INFILE => $file, // this refers to 's3://path-to-object' 
    CURLOPT_INFILESIZE => $size, 
    CURLOPT_UPLOAD => true, 
    CURLOPT_HTTPHEADER => array('Expect: ', 'Content-Range: replaced...') 
); 
+0

這就是我目前的解決方法,但我試圖繞過下載一步。謝謝! –

+0

我想有些應用程序需要使數據流,所以我沒有看到一個解決方案,但沒有下載文件到目前爲止 –

+0

當你PUT時,你正在上傳一個具體的對象。數據流不是這樣的。它沒有有限的大小。 – miken32