我尝试使用v2 api从dropbox下载文件并将其上传到amazon s3
在这里下载文件是我做的:
$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);
以上代码在" application / octet-stream"中返回响应我假设,所以我的第一个问题是将此流转换为文件并将其上传到s3
我有这个代码,它采用文件的物理路径并将其上传到s3但在上面的例子中我有流
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';
}
所以问题是将流转换为文件并上传到s3,如何更改上面的代码来做到这一点
提前致谢。