6minioUpdateCest.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. use Symfony\Component\Finder\Finder;
  3. // Include the SDK using the Composer autoloader
  4. date_default_timezone_set('America/Argentina/Buenos_Aires');
  5. require 'vendor/autoload.php';
  6. class minioUpdateCest
  7. {
  8. public function minioUpdate()
  9. {
  10. $cliente= 'galvez';
  11. $s3 = new Aws\S3\S3Client([
  12. 'version' => 'latest',
  13. 'region' => 'sa-east-1',
  14. 'endpoint' => 'https://s3.infra.flowdat.com/minio/login',
  15. 'use_path_style_endpoint' => true,
  16. 'credentials' => [
  17. 'key' => 'iksop',
  18. 'secret' => '8htoiwn44g204th',
  19. ],
  20. ]);
  21. # subo últimas screen
  22. $head = shell_exec('git rev-parse HEAD');
  23. $head = substr($head,0,-1);
  24. $directorioA = array('01_login/','02_base/','03_ftth/','04_map/','05_stats/');
  25. $cantdir= count($directorioA);
  26. for ($i = 0; $i < $cantdir; $i++)
  27. {
  28. $dir = $directorioA[$i];
  29. $directorio = opendir("./tests/_output/debug/". $cliente. "/" . $head ."/" . $dir);
  30. while ($archivo = readdir($directorio))
  31. {
  32. if (is_dir($archivo))
  33. {
  34. }
  35. else
  36. {
  37. $result = $s3->putObject(array(
  38. 'Bucket' => 'testbucket',
  39. 'Key' => $cliente . "/" . $head. '/'.$dir . $archivo,
  40. 'SourceFile' => './tests/_output/debug/'.$cliente . "/" . $head . "/" . $dir . $archivo
  41. ));
  42. // We can poll the object until it is accessible
  43. $s3->waitUntil('ObjectExists', array(
  44. 'Bucket' => 'testbucket',
  45. 'Key' => $cliente . "/" . $head. '/'.$dir . $archivo
  46. ));
  47. }
  48. }
  49. echo "Directorio '" . $dir . "' actualizado. Commit: " . $head . " Cliente: " . $cliente ."\n" ;
  50. }
  51. //descargar imagenes Source
  52. $s3 = new Aws\S3\S3Client([
  53. 'version' => 'latest',
  54. 'region' => 'sa-east-1',
  55. 'endpoint' => 'https://s3.infra.flowdat.com/minio/login',
  56. 'use_path_style_endpoint' => true,
  57. 'credentials' => [
  58. 'key' => 'iksop',
  59. 'secret' => '8htoiwn44g204th',
  60. ],
  61. ]);
  62. for ($i = 0; $i < $cantdir; $i++)
  63. {
  64. $dir = $directorioA[$i];
  65. shell_exec('mkdir -p ./tests/screenSRC/'. $cliente . "/" . $dir);
  66. }
  67. $iterator = $s3->getIterator('ListObjects', array('Bucket'=> "screen-source",'Prefix'=> $cliente));
  68. foreach ($iterator as $object)
  69. {
  70. //     echo $object['Key'];
  71. $retrive = $s3->getObject([
  72. 'Bucket' => 'screen-source',
  73. 'Key' => $object['Key'],
  74. 'SaveAs' => './tests/screenSRC/' . $object['Key']
  75. ]);
  76. echo "Se descargó el archivo " . $object['Key'] . "\n";
  77. }
  78. }
  79. }