我有此代码,需要从一个s3复制到另一个。
我在hook_entity_insert()中编写代码
我还想在一个存储桶中删除文件后立即将其删除到另一个存储桶中
function <your_module>_entity_insert(Drupal\Core\Entity\EntityInterface $entity) {
if(($entity->bundle() === '<your_bundle_name>')){
//Uploading file
$s3config = \Drupal::config('s3fs.settings');
$awsAccessKey = $s3config->get('access_key');
$awsSecretKey = $s3config->get('secret_key');
$ToBucket = <your_bucket>;
$FromBucket = <your_bucket>;
$fullpath= <your_path>;
// Instantiate the client.
$s3 = S3Client::factory(array(
'version' => 'latest',
'region' => $region,
'credentials' => array(
'key' => $awsAccessKey,
'secret' => $awsSecretKey,
))
);
}
}