繁体   English   中英

来自 Amazon S3 流包装器的 PHP CURL PUT(tcp 流)

[英]PHP CURL PUT from Amazon S3 stream wrapper (tcp stream)

我正在尝试 (PHP) 使用 S3 流包装器(s3://...) cURL PUT 一个文件从 Amazon S3 到 Vimeo 并收到以下错误:

curl_setopt_array():不能将 tcp_socket/ssl 类型的流表示为 [...] 中的 STDIO 文件

有没有办法 cURL PUT 远程文件? 这是发送的 curl 选项:

$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...')
);

在 PUT 之前将文件保存到本地服务器:

$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...')
);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM