example.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. // Include the SDK using the Composer autoloader
  3. date_default_timezone_set('America/Argentina/Buenos_Aires');
  4. require 'vendor/autoload.php';
  5. $s3 = new Aws\S3\S3Client([
  6. 'version' => 'latest',
  7. 'region' => 'sa-east-1',
  8. 'endpoint' => 'https://s3.infra.flowdat.com/minio/login',
  9. 'use_path_style_endpoint' => true,
  10. 'credentials' => [
  11. 'key' => 'iksop',
  12. 'secret' => '8htoiwn44g204th',
  13. ],
  14. ]);
  15. // Send a PutObject request and get the result object.
  16. $insert = $s3->putObject([
  17. 'Bucket' => 'testbucket',
  18. 'Key' => 'testFer',
  19. 'Body' => 'Hello Fer!!'."\n"
  20. ]);
  21. // Download the contents of the object.
  22. $retrive = $s3->getObject([
  23. 'Bucket' => 'testbucket',
  24. 'Key' => 'testFer',
  25. 'SaveAs' => 'testkey_local'
  26. ]);
  27. $directorio = opendir("tests/comp/");
  28. while ($archivo = readdir($directorio))
  29. {
  30. if (is_dir($archivo))
  31. {
  32. }
  33. else
  34. {
  35. $result = $s3->putObject(array(
  36. 'Bucket' => 'testbucket',
  37. 'Key' => 'dir/'.$archivo,
  38. 'SourceFile' => '/home/iksop/Escritorio/te/installer/behat/testScreenshot/tests/comp/' . $archivo
  39. ));
  40. // We can poll the object until it is accessible
  41. $s3->waitUntil('ObjectExists', array(
  42. 'Bucket' => 'testbucket',
  43. 'Key' => 'dir/'.$archivo
  44. ));
  45. }
  46. }
  47. // Print the body of the result by indexing into the result object.
  48. echo $retrive['Body'];