2017-03-08 62 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