1

I'm trying to (PHP) cURL PUT a file from Amazon S3 to Vimeo using S3 stream wrapper (s3://...) and getting the follow error:

curl_setopt_array(): cannot represent a stream of type tcp_socket/ssl as a STDIO FILE in [...]

Is there a way to cURL PUT a remote file? This are the curl opts being sent:

$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...')
);
Machavity
  • 30,841
  • 27
  • 92
  • 100
Martin Buezas
  • 384
  • 2
  • 9

1 Answers1

1

Save the file to your local server before PUTting it:

$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...')
);
miken32
  • 42,008
  • 16
  • 111
  • 154