im trying to download the file from dropbox using v2 api and upload it to amazon s3
to download file here is what i did:
$headers= array(
'Content-Type: ',
"Authorization: Bearer EkOrS5mbVAwA....",
"Dropbox-API-Arg: {\"path\": \"/clients/erbrecht, kenneth/2nd dispute erbrecht.docx\"}");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://content.dropboxapi.com/2/files/download');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
//curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
the code above returned response in "application/octet-stream" i assume, so my first problem is to convert this stream to a file and upload it to s3
i have this code that takes physical path of the file and upload it to s3 but in the above case i have the stream
try{
$s3 = Aws\S3\S3Client::factory(array(
'region' => S3_REGION,
'version' => 'latest',
'credentials' => array(
'key' => S3_ACCESS_KEY,
'secret' => S3_SECRET_KEY,
)
));
$s3->putObject([
'Bucket' => $this->s3bucket,
'Key' => "uploads/{$name}",
'Body' => fopen($path,'rb'),
'ACL' => 'public-read'
]);
return '';
}catch(S3Exception $e){
//return $e->getMessage();
return 'Error Uploading File, Please try again';
}
so the problem is to convert stream to file and upload to s3, how can i change the above code to do that
Thanks in advance.