Amazon S3 in Perl

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

2 comments

Comments 1 - 2 of 2 previous next Post a comment

  • + polettix Flavio Poletti 1 month ago
    Absolutely - in slide 30 I only changed to Italian once... Why are we commenting an Italian presentation in English?!?
  • + cstrep Cosimo Streppone 1 month ago
    Here I think $proprietario should be $owner? :-)
Post a comment
Embed Video
Edit your comment Cancel

1 Favorite & 1 Event

Amazon S3 in Perl - Presentation Transcript

  1. Amazon S3 Perl Web Client
  2. ?
  3. http://aws.amazon.com/s3/
  4. Repository Repository Repository Amazon S3 Client
  5. Repository Repository Repository ? Amazon S3 Client
  6. $
  7. Repository Repository Repository Amazon S3 Client
  8. Repository Repository Repository Amazon S3 HTTP Client
  9. Repository Repository Repository Amazon S3 HTTP Client
  10. Repository Repository Repository Amazon S3 HTTP Client
  11. Oggetto/File
  12. Chiave => Valore
  13. 1 byte - 5 Gbyte
  14. 1 byte - 5 Gbyte
  15. 1 byte - 5 Gbyte
  16. 1 byte - 5 Gbyte Non in scala!
  17. Quanti ne volete
  18. Bucket
  19. Fino a 100
  20. Nome Univoco
  21. Net::Amazon::S3
  22. ->new() use Net::Amazon::S3; my $s3 = Net::Amazon::S3->new({ aws_access_key_id => 'chiave-aws', aws_secret_access_key => 'shhhh!', retry => 1, });
  23. ->new() use Net::Amazon::S3; my $s3 = Net::Amazon::S3->new({ aws_access_key_id => 'chiave-aws', aws_secret_access_key => 'shhhh!', retry => 1, });
  24. ->new() use Net::Amazon::S3; my $s3 = Net::Amazon::S3->new({ aws_access_key_id => 'chiave-aws', aws_secret_access_key => 'shhhh!', retry => 1, }); http://aws.amazon.com/s3/
  25. retry
  26. retry secure
  27. retry secure timeout
  28. ->buckets() my $buckets = $s3->buckets(); my $owner = $buckets->{owner_displayname}; my $owner_id = $buckets->{owner_id}; say "Bucket di $proprietario ", "($owner_id):";
  29. ->buckets() my $aref = $buckets->{buckets}; for my $bucket (@$aref) { my $nome = $bucket->bucket(); my $data = $bucket->creation_date(); say "t$nome, creato il $data"; }
  30. ->add_bucket() my $bucket = $s3->add_bucket({ bucket => ’foto-pippo’, acl_short => ’public-read’, # location_constraint => ’EU’, });
  31. ->add_bucket() my $bucket = $s3->add_bucket({ bucket => ’foto-pippo’, acl_short => ’public-read’, # location_constraint => ’EU’, });
  32. ->add_bucket() my $bucket = $s3->add_bucket({ bucket => ’foto-pippo’, acl_short => ’public-read’, # location_constraint => ’EU’, });
  33. ->add_bucket() my $bucket = $s3->add_bucket({ bucket => ’foto-pippo’, acl_short => ’public-read’, # location_constraint => ’EU’, });
  34. Dice il Saggio:
  35. “No Lettere Maiuscole!”
  36. acl_short?
  37. public-read
  38. private public-read
  39. private authenticated-read public-read
  40. private authenticated-read public-read public-read-write
  41. Eliminazione
  42. Eliminazione $s3->delete_bucket( {bucket => ’buttami-via’});
  43. Eliminazione $s3->delete_bucket( {bucket => ’buttami-via’}); $s3->delete_bucket($bucket);
  44. Eliminazione $s3->delete_bucket( {bucket => ’buttami-via’}); $s3->delete_bucket($bucket); $bucket->delete_bucket();
  45. Ricordate: 100 bucket!
  46. Chiavi
  47. list_bucket() my $risultato = $s3->list_bucket({ bucket => ’photo’, });
  48. Limiti
  49. list_bucket() my $risultato = $s3->list_bucket({ bucket => ’photo’, max_keys => 100, prefix => ’immagini/’, delimiter => ’/’, });
  50. list_bucket() my $risultato = $s3->list_bucket({ bucket => ’photo’, max_keys => 100, prefix => ’immagini/’, delimiter => ’/’, });
  51. list_bucket() my $risultato = $s3->list_bucket({ bucket => ’photo’, max_keys => 100, prefix => ’immagini/’, delimiter => ’/’, });
  52. prefix immagini/vacanze/IMG_0001.JPG immagini/vacanze/IMG_0002.JGP immagini/vacanze/IMG_0003.JGP immagini/tizio.jpg immagini/caio.png lavoro/boh.pdf
  53. list_bucket() my $risultato = $s3->list_bucket({ bucket => ’photo’, max_keys => 100, prefix => ’immagini/’, delimiter => ’/’, });
  54. prefix + delimiter immagini/vacanze/IMG_0001.JPG immagini/vacanze/IMG_0002.JGP immagini/vacanze/IMG_0003.JGP immagini/tizio.jpg immagini/caio.png lavoro/boh.pdf
  55. risultato immagini/vacanze immagini/tizio.jpg immagini/caio.png
  56. risultato prefisso “comune”! immagini/vacanze immagini/tizio.jpg immagini/caio.png
  57. marker
  58. lista di una “directory” my %ricerca = ( bucket => ’photo’, prefix => ’immagini/’, delimiter => ’/’, );
  59. lista di una “directory” while (1) { my $risultato = $s3->list_bucket(%ricerca) or die ’errore’; say "dir : $_" for @{ $risultato->{common_prefixes} }; say "file: $_->{key}" for @{ $risultato->{keys} }; last unless $risultato->{is_truncated}; $impostazioni_ricerca{marker} = $risultato->{next_marker}; }
  60. lista di una “directory” while (1) { my $risultato = $s3->list_bucket(%ricerca) or die ’errore’; say "dir : $_" for @{ $risultato->{common_prefixes} }; say "file: $_->{key}" for @{ $risultato->{keys} }; last unless $risultato->{is_truncated}; $impostazioni_ricerca{marker} = $risultato->{next_marker}; }
  61. lista di una “directory” while (1) { my $risultato = $s3->list_bucket(%ricerca) or die ’errore’; say "dir : $_" for @{ $risultato->{common_prefixes} }; say "file: $_->{key}" for @{ $risultato->{keys} }; last unless $risultato->{is_truncated}; $impostazioni_ricerca{marker} = $risultato->{next_marker}; }
  62. lista di una “directory” while (1) { my $risultato = $s3->list_bucket(%ricerca) or die ’errore’; say "dir : $_" for @{ $risultato->{common_prefixes} }; say "file: $_->{key}" for @{ $risultato->{keys} }; last unless $risultato->{is_truncated}; $impostazioni_ricerca{marker} = $risultato->{next_marker}; }
  63. lista di una “directory” while (1) { my $risultato = $s3->list_bucket(%ricerca) or die ’errore’; say "dir : $_" for @{ $risultato->{common_prefixes} }; say "file: $_->{key}" for @{ $risultato->{keys} }; last unless $risultato->{is_truncated}; $impostazioni_ricerca{marker} = $risultato->{next_marker}; }
  64. lista di una “directory” while (1) { my $risultato = $s3->list_bucket(%ricerca) or die ’errore’; say "dir : $_" for @{ $risultato->{common_prefixes} }; say "file: $_->{key}" for @{ $risultato->{keys} }; last unless $risultato->{is_truncated}; $impostazioni_ricerca{marker} = $risultato->{next_marker}; }
  65. Perl, baby
  66. lista di una “directory” my $risultato = $s3->list_bucket_all({ bucket => ’photo’, prefix => ’immagini/’, delimiter => ’/’, }); say "dir : $_" for @{ $risultato->{common_prefixes} }; say "file: $_->{key}" for @{ $risultato->{keys} };
  67. Oggetti, finalmente!
  68. Aggiunta my $bucket = $s3->bucket(’bucket-lavoro’); $bucket->add_key(’un/file/allegro‘ => "Ciao a tutti!n");
  69. Aggiunta $bucket->add_key(chiave => ‘valore!’, { content_type => ’text/plain’, acl_short => ’public-read’, ’x-amz-meta-info’ => ’baz!!!’, } );
  70. Aggiunta $bucket->add_key_filename( ‘mio/file.txt’, ‘/path/to/file.txt’, )
  71. Download my $bucket = $s3->bucket(’il-mio-bucket’); my $dati = $bucket->get_key(’un/file/allegro’);
  72. Download my $bucket = $s3->bucket(’il-mio-bucket’); my $dati = $bucket->get_key(’un/file/allegro’);
  73. Download $dati = { content_type => ‘text/plain’, etag => ‘44b6...f367’, content => “Ciao a tutti!n”, # ... };
  74. Download my $bucket = $s3->bucket(’il-mio-bucket’); my $dati = $bucket->get_key_filename( ’un/file/allegro’, undef, ‘/salvalo/qui’);
  75. Download per eccellenza
  76. public_read public_read_write
  77. http:// bucket.s3.amazonaws.com/ chiave
  78. http:// polettix.s3.amazonaws.com/ tmp/pwc.tar.gz
  79. Net::Amazon::S3::ACL
  80. Attori
  81. Attori • proprietario
  82. Attori • proprietario • altro utente Amazon S3
  83. Attori • proprietario • altro utente Amazon S3 • tutti gli utenti Amazon S3
  84. Attori • proprietario • altro utente Amazon S3 • tutti gli utenti Amazon S3 • tutti
  85. Diritti
  86. Diritti • lettura
  87. Diritti • lettura • scrittura
  88. Diritti • lettura • scrittura • lettura ACP
  89. Diritti • lettura • scrittura • lettura ACP • scrittura ACP
  90. Diritti • lettura • scrittura • lettura ACP • scrittura ACP • controllo completo
  91. N::A::S::ACL use Net::Amazon::S3::ACL; my $acl = Net::Amazon::S3::ACL->new(); my $acl_xml = $bucket->get_acl(’etc/passwd’); $acl->parse($acl_xml); say $acl->stringify(); # XML say $acl->dump(); # YAML, se presente
  92. ->add() $acl->add( ’foo@example.com’ => ’WRITE’, ALL => ’READ’, ’dfadffadf...‘ => ’*’, );
  93. set_acl() $bucket->set_acl({ key => $chiave, acl_xml => $acl->stringify(), });
  94. Upload da esterni
  95. Net::Amazon::S3::Policy
  96. F M Net::Amazon::S3::Policy T R
  97. F M Net::Amazon::S3::Policy T R Friendly
  98. ?
  99. !

+ Flavio PolettiFlavio Poletti, 1 month ago

custom

168 views, 1 favs, 1 embeds more stats

Usare Amazon S3 in Perl può essere più semplice d more

More info about this document

CC Attribution License

Go to text version

  • Total Views 168
    • 166 on SlideShare
    • 2 from embeds
  • Comments 2
  • Favorites 1
  • Downloads 2
Most viewed embeds
  • 2 views on http://www.polettix.it

more

All embeds
  • 2 views on http://www.polettix.it

less

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel
File a copyright complaint
Having problems? Go to our helpdesk?

Categories

Groups / Events