minioUpdate.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. $s3 = new Aws\S3\S3Client([
  7. 'version' => 'latest',
  8. 'region' => 'sa-east-1',
  9. 'endpoint' => 'https://s3.infra.flowdat.com/minio/login',
  10. 'use_path_style_endpoint' => true,
  11. 'credentials' => [
  12. 'key' => 'iksop',
  13. 'secret' => '8htoiwn44g204th',
  14. ],
  15. ]);
  16. /* Send a PutObject request and get the result object.
  17. $insert = $s3->putObject([
  18. 'Bucket' => 'testbucket',
  19. 'Key' => 'testFer',
  20. 'Body' => 'Hello Fer!!'."\n"
  21. ]);
  22. // Download the contents of the object.
  23. $retrive = $s3->getObject([
  24. 'Bucket' => 'testbucket',
  25. 'Key' => 'testFer',
  26. 'SaveAs' => 'testkey_local'
  27. ]);
  28. */
  29. $head = shell_exec('git rev-parse HEAD');
  30. $head = substr($head,0,-1);
  31. $directorioA = array('01_login/','02_base/','03_ftth/','04_map/');
  32. for ($i = 0; $i < 4; $i++)
  33. {
  34. $dir = $directorioA[$i];
  35. $directorio = opendir("tests/_output/debug/" . $dir);
  36. while ($archivo = readdir($directorio))
  37. {
  38. if (is_dir($archivo))
  39. {
  40. }
  41. else
  42. {
  43. $result = $s3->putObject(array(
  44. 'Bucket' => 'testbucket',
  45. 'Key' => $head.'/'.$dir . $archivo,
  46. 'SourceFile' => './tests/_output/debug/' . $dir . $archivo
  47. ));
  48. // We can poll the object until it is accessible
  49. $s3->waitUntil('ObjectExists', array(
  50. 'Bucket' => 'testbucket',
  51. 'Key' => $head.'/'.$dir . $archivo
  52. ));
  53. }
  54. }
  55. echo "Directorio '" . $dir . "' actualizado. Commit: " . $head . "\n" ;
  56. }
  57. //descargar HEAD~1
  58. $s3 = new Aws\S3\S3Client([
  59. 'version' => 'latest',
  60. 'region' => 'sa-east-1',
  61. 'endpoint' => 'https://s3.infra.flowdat.com/minio/login',
  62. 'use_path_style_endpoint' => true,
  63. 'credentials' => [
  64. 'key' => 'iksop',
  65. 'secret' => '8htoiwn44g204th',
  66. ],
  67. ]);
  68. $head = shell_exec('git rev-parse HEAD~1');
  69. $head = substr($head,0,-1);
  70. for ($i = 0; $i < 4; $i++)
  71. {
  72. $dir = $directorioA[$i];
  73. shell_exec('mkdir -p ./tests/to_compare/' . $head . "/" . $dir);
  74. }
  75. $iterator = $s3->getIterator('ListObjects', array('Bucket'=> "testbucket",'Prefix'=> $head));
  76. foreach ($iterator as $object) {
  77. //     echo "Objeto cargado: " . $object['Key'];
  78. $retrive = $s3->getObject([
  79. 'Bucket' => 'testbucket',
  80. 'Key' => $object['Key'],
  81. 'SaveAs' => './tests/to_compare/' . $object['Key']
  82. ]);
  83. echo "Se descargó el archivo " . $object['Key'] . "\n";
  84. }
  85. // Print the body of the result by indexing into the result object.
  86. //echo $retrive['Body'];