Class: RubyS3Cmd::S3Cmd
- Inherits:
-
Object
- Object
- RubyS3Cmd::S3Cmd
- Defined in:
- lib/ruby-s3cmd/s3cmd.rb
Overview
class RubyS3CMD::S3Cmd.new( array, str, array)
Instance Attribute Summary collapse
-
#acl_private ⇒ Object
Store objects with default ACL allowing access for you only.
-
#acl_public ⇒ Object
Store objects with permissions allowing read for anyone.
-
#add_header ⇒ Object
Add a given HTTP header to the upload request.
-
#bucket_location ⇒ Object
Specify datacentre where to create the bucket.
-
#cf_add_cname ⇒ Object
Add given CNAME to a CloudFront distribution (only for cfcreate and cfmodify commands).
-
#cf_comment ⇒ Object
Set COMMENT for a given CloudFront distribution (only for cfcreate and cfmodify commands).
-
#cf_remove_cname ⇒ Object
Remove given CNAME from a CloudFront distribution (only for cfmodify command).
-
#config ⇒ Object
Config file name.
-
#continue ⇒ Object
Continue getting a partially downloaded file (only for get command).
-
#debug ⇒ Object
Enable debug output.
-
#delete_removed ⇒ Object
Delete remote objects with no corresponding local file when syncing to S3 or delete local files with no corresponding object in S3 when syncing from S3.
-
#disable ⇒ Object
Enable given CloudFront distribution (only for cfmodify command).
-
#dry_run ⇒ Object
Only show what should be uploaded or downloaded but don’t actually do it.
-
#enable ⇒ Object
Enable given CloudFront distribution (only for cfmodify command).
-
#encoding ⇒ Object
Override autodetected terminal and filesystem encoding (character set).
-
#encrypt ⇒ Object
Use GPG encryption to protect stored objects from unauthorized access.
-
#exclude ⇒ Object
Exclude files matching GLOB (a.k.a. shell-style wildcard) from sync.
-
#exclude_from ⇒ Object
Same as –exclude but reads GLOBs from the given FILE instead of expecting them on the command line.
-
#force ⇒ Object
Force overwrite and other dangerous operations.
-
#guess_mime_type ⇒ Object
Guess MIME‐type of files by their extension.
-
#human_readable_sizes ⇒ Object
Print sizes in human readable form.
-
#include ⇒ Object
Filenames and paths matching GLOB or REGEXP will be included even if previously excluded by one of –®exclude(-from) patterns.
-
#include_from ⇒ Object
FILE.
-
#list_md5 ⇒ Object
Include MD5 sums in bucket listings (only for ls command).
-
#mime_type ⇒ Object
Default MIME-type to be set for objects stored.
-
#no_delete_removed ⇒ Object
Don’t delete remote objects.
-
#no_encrypt ⇒ Object
Don’t encrypt files.
-
#no_preserve ⇒ Object
Don’t store filesystem attributes with uploaded files.
-
#no_progress ⇒ Object
Display or don’t display progress meter.
-
#path_to_s3cmd ⇒ Object
Sets the executable path, otherwise the environment path will be used.
-
#preserve ⇒ Object
Preserve filesystem attributes (mode, ownership, timestamps).
-
#progress ⇒ Object
Display or don’t display progress meter.
-
#recursive ⇒ Object
Recursive upload, download or removal.
-
#rexclude ⇒ Object
Same as –exclude but works with REGEXPs (Regular expressions).
-
#rexclude_from ⇒ Object
Same as –exclude-from but works with REGEXPs.
-
#rinclude ⇒ Object
REGEXP.
-
#rinclude_from ⇒ Object
FILE.
-
#skip_existing ⇒ Object
Skip over files that exist at the destination (only for get and sync commands).
-
#verbose ⇒ Object
Enable verbose output.
Instance Method Summary collapse
-
#cfcreate(bucket) ⇒ Object
Create CloudFront distribution point.
-
#cfdelete(dist_id) ⇒ Object
Delete CloudFront distribution point.
-
#cfinfo(dist_id) ⇒ Object
Display CloudFront distribution point parameters.
-
#cflist ⇒ Object
List CloudFront distribution points.
-
#cfmodify(dist_id) ⇒ Object
Change CloudFront distribution point parameters.
-
#configure ⇒ Object
Invoke interactive (re)configuration tool.
-
#cp(src_bucket, dest_bucket) ⇒ Object
Make a copy of a file (cp) or move a file (mv).
-
#del(bucket) ⇒ Object
Delete file from bucket.
-
#du(bucket) ⇒ Object
Disk usage - amount of data stored in S3.
-
#dump_config ⇒ Object
Dump current configuration after parsing config files and command line options and exit.
-
#get(bucket, local_file) ⇒ Object
Get file from bucket (i.e. download from S3).
-
#help ⇒ Object
Show the help message and exit.
-
#info(bucket) ⇒ Object
Get various information about a Bucket or Object.
-
#initialize ⇒ S3Cmd
constructor
Returns a new RubyS3CMD::S3Cmd Object.
-
#la ⇒ Object
List all object in all buckets.
-
#ls(bucket) ⇒ Object
List objects or buckets.
-
#mb(bucket) ⇒ Object
Make bucket.
-
#mv(src_bucket, dest_bucket) ⇒ Object
Make a copy of a file (cp) or move a file (mv).
-
#put(files, bucket) ⇒ Object
Put file into bucket (i.e. upload to S3).
-
#rb(bucket) ⇒ Object
Remove bucket.
-
#setacl(bucket) ⇒ Object
Modify Access control list for Bucket or Files.
- #show_config ⇒ Object
-
#sync(src_object, dest_object) ⇒ Object
Backup a directory tree to S3 Restore a tree from S3 to local directory.
-
#version ⇒ Object
Show s3cmd version and exit.
Constructor Details
#initialize ⇒ S3Cmd
Returns a new RubyS3CMD::S3Cmd Object
228 229 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 228 def initialize() end |
Instance Attribute Details
#acl_private ⇒ Object
Store objects with default ACL allowing access for you only.
176 177 178 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 176 def acl_private @acl_private end |
#acl_public ⇒ Object
Store objects with permissions allowing read for anyone. See s3tools.org/s3cmd-public for details and hints for storing publicly accessible files.
171 172 173 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 171 def acl_public @acl_public end |
#add_header ⇒ Object
Add a given HTTP header to the upload request. Can be used multiple times with different header names. For instance set ‘Expires’ or ‘Cache-Control’ headers (or both) using this options if you like.
165 166 167 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 165 def add_header @add_header end |
#bucket_location ⇒ Object
Specify datacentre where to create the bucket. Possible values are US (default) or EU.
32 33 34 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 32 def bucket_location @bucket_location end |
#cf_add_cname ⇒ Object
Add given CNAME to a CloudFront distribution (only for cfcreate and cfmodify commands)
208 209 210 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 208 def cf_add_cname @cf_add_cname end |
#cf_comment ⇒ Object
Set COMMENT for a given CloudFront distribution (only for cfcreate and cfmodify commands)
218 219 220 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 218 def cf_comment @cf_comment end |
#cf_remove_cname ⇒ Object
Remove given CNAME from a CloudFront distribution (only for cfmodify command)
213 214 215 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 213 def cf_remove_cname @cf_remove_cname end |
#config ⇒ Object
Config file name. Defaults to $HOME/.s3cfg
73 74 75 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 73 def config @config end |
#continue ⇒ Object
Continue getting a partially downloaded file (only for get command). This comes handy once download of a large file, say an ISO image, from a S3 bucket fails and a partially downloaded file is left on the disk. Unfortunately put command doesn’t support restarting of failed upload due to Amazon S3 limitations.
142 143 144 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 142 def continue @continue end |
#debug ⇒ Object
Enable debug output.
64 65 66 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 64 def debug @debug end |
#delete_removed ⇒ Object
Delete remote objects with no corresponding local file when syncing to S3 or delete local files with no corresponding object in S3 when syncing from S3.
89 90 91 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 89 def delete_removed @delete_removed end |
#disable ⇒ Object
Enable given CloudFront distribution (only for cfmodify command)
203 204 205 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 203 def disable @disable end |
#dry_run ⇒ Object
Only show what should be uploaded or downloaded but don’t actually do it. May still perform S3 requests to get bucket listings and other in formation though.
83 84 85 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 83 def dry_run @dry_run end |
#enable ⇒ Object
Enable given CloudFront distribution (only for cfmodify command)
198 199 200 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 198 def enable @enable end |
#encoding ⇒ Object
Override autodetected terminal and filesystem encoding (character set).
54 55 56 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 54 def encoding @encoding end |
#encrypt ⇒ Object
Use GPG encryption to protect stored objects from unauthorized access. See s3tools.org/s3cmd- public for details about encryption.
182 183 184 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 182 def encrypt @encrypt end |
#exclude ⇒ Object
Exclude files matching GLOB (a.k.a. shell-style wildcard) from sync. See FILE TRANSFERS section and s3tools.org/s3cmd-sync for more information.
110 111 112 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 110 def exclude @exclude end |
#exclude_from ⇒ Object
Same as –exclude but reads GLOBs from the given FILE instead of expecting them on the command line.
115 116 117 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 115 def exclude_from @exclude_from end |
#force ⇒ Object
Force overwrite and other dangerous operations. Can be used to remove a non-empty buckets with s3cmd rb –force s3://bkt
27 28 29 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 27 def force @force end |
#guess_mime_type ⇒ Object
Guess MIME‐type of files by their extension. Falls back to default MIME‐Type as specified by –mime-type option
158 159 160 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 158 def guess_mime_type @guess_mime_type end |
#human_readable_sizes ⇒ Object
Print sizes in human readable form.
37 38 39 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 37 def human_readable_sizes @human_readable_sizes end |
#include ⇒ Object
Filenames and paths matching GLOB or REGEXP will be included even if previously excluded by one of –®exclude(-from) patterns
131 132 133 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 131 def include @include end |
#include_from ⇒ Object
FILE
132 133 134 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 132 def include_from @include_from end |
#list_md5 ⇒ Object
Include MD5 sums in bucket listings (only for ls command).
42 43 44 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 42 def list_md5 @list_md5 end |
#mime_type ⇒ Object
Default MIME-type to be set for objects stored.
152 153 154 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 152 def mime_type @mime_type end |
#no_delete_removed ⇒ Object
Don’t delete remote objects. Default for sync command.
94 95 96 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 94 def no_delete_removed @no_delete_removed end |
#no_encrypt ⇒ Object
Don’t encrypt files.
187 188 189 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 187 def no_encrypt @no_encrypt end |
#no_preserve ⇒ Object
Don’t store filesystem attributes with uploaded files.
104 105 106 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 104 def no_preserve @no_preserve end |
#no_progress ⇒ Object
Display or don’t display progress meter. When running on TTY (e.g. console or xterm) the default is to display progress meter. If not on TTY (e.g. output is redirected somewhere or running from cron) the default is to not display progress meter.
49 50 51 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 49 def no_progress @no_progress end |
#path_to_s3cmd ⇒ Object
Sets the executable path, otherwise the environment path will be used.
223 224 225 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 223 def path_to_s3cmd @path_to_s3cmd end |
#preserve ⇒ Object
Preserve filesystem attributes (mode, ownership, timestamps). Default for sync command.
99 100 101 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 99 def preserve @preserve end |
#progress ⇒ Object
Display or don’t display progress meter. When running on TTY (e.g. console or xterm) the default is to display progress meter. If not on TTY (e.g. output is redirected somewhere or running from cron) the default is to not display progress meter.
49 50 51 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 49 def progress @progress end |
#recursive ⇒ Object
Recursive upload, download or removal. When used with del it can remove all the files in a bucket.
21 22 23 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 21 def recursive @recursive end |
#rexclude ⇒ Object
Same as –exclude but works with REGEXPs (Regular expressions).
120 121 122 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 120 def rexclude @rexclude end |
#rexclude_from ⇒ Object
Same as –exclude-from but works with REGEXPs.
125 126 127 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 125 def rexclude_from @rexclude_from end |
#rinclude ⇒ Object
REGEXP
133 134 135 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 133 def rinclude @rinclude end |
#rinclude_from ⇒ Object
FILE
134 135 136 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 134 def rinclude_from @rinclude_from end |
#skip_existing ⇒ Object
Skip over files that exist at the destination (only for get and sync commands).
147 148 149 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 147 def skip_existing @skip_existing end |
#verbose ⇒ Object
Enable verbose output.
59 60 61 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 59 def verbose @verbose end |
Instance Method Details
#cfcreate(bucket) ⇒ Object
Create CloudFront distribution point
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 647 def cfcreate(bucket) # s3://BUCKET tmp = Tempfile.new('tmp') command = option_string() + "cfcreate " + bucket.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#cfdelete(dist_id) ⇒ Object
Delete CloudFront distribution point
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 668 def cfdelete(dist_id) # cf://DIST_ID tmp = Tempfile.new('tmp') command = option_string() + "cfdelete " + dist_id.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#cfinfo(dist_id) ⇒ Object
Display CloudFront distribution point parameters
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 626 def cfinfo(dist_id) # [cf://DIST_ID] tmp = Tempfile.new('tmp') command = option_string() + "cfinfo " + dist_id.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#cflist ⇒ Object
List CloudFront distribution points
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 605 def cflist tmp = Tempfile.new('tmp') command = option_string() + "cflist " + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#cfmodify(dist_id) ⇒ Object
Change CloudFront distribution point parameters
689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 689 def cfmodify(dist_id) # cf://DIST_ID tmp = Tempfile.new('tmp') command = option_string() + "cfmodify " + dist_id.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#configure ⇒ Object
Invoke interactive (re)configuration tool. Don’t worry, you won’t lose your settings on subsequent runs.
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 281 def configure tmp = Tempfile.new('tmp') command = option_string() + "--configure " + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#cp(src_bucket, dest_bucket) ⇒ Object
Make a copy of a file (cp) or move a file (mv). Destination can be in the same bucket with a dif‐ ferent name or in another bucket with the same or different name. Adding –acl-public will make the destination object publicly accessible (see below).
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 496 def cp(src_bucket, dest_bucket) # s3://BUCKET1/OBJECT1 s3://BUCKET2[/OBJECT2] tmp = Tempfile.new('tmp') command = option_string() + "cp " + src_bucket.to_s + " " + dest_bucket.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#del(bucket) ⇒ Object
Delete file from bucket
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 451 def del(bucket) # s3://BUCKET/OBJECT tmp = Tempfile.new('tmp') command = option_string() + "del " + bucket.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#du(bucket) ⇒ Object
Disk usage - amount of data stored in S3
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 582 def du(bucket) # [s3://BUCKET[/PREFIX]] tmp = Tempfile.new('tmp') command = option_string() + "du " + bucket.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#dump_config ⇒ Object
Dump current configuration after parsing config files and command line options and exit.
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 304 def dump_config tmp = Tempfile.new('tmp') command = option_string() + "--dump-config " + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#get(bucket, local_file) ⇒ Object
Get file from bucket (i.e. download from S3)
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 430 def get(bucket, local_file) # s3://BUCKET/OBJECT LOCAL_FILE tmp = Tempfile.new('tmp') command = option_string() + "get " + bucket.to_s + " " + local_file.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#help ⇒ Object
Show the help message and exit
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 234 def help tmp = Tempfile.new('tmp') command = option_string() + "--help " + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#info(bucket) ⇒ Object
Get various information about a Bucket or Object
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 561 def info(bucket) # s3://BUCKET[/OBJECT] tmp = Tempfile.new('tmp') command = option_string() + "info " + bucket.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#la ⇒ Object
List all object in all buckets
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 388 def la tmp = Tempfile.new('tmp') command = option_string() + "la " + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#ls(bucket) ⇒ Object
List objects or buckets
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 367 def ls(bucket) # s3://BUCKET[/PREFIX]] tmp = Tempfile.new('tmp') command = option_string() + "ls " + bucket.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#mb(bucket) ⇒ Object
Make bucket
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 325 def mb(bucket) # s3://BUCKET tmp = Tempfile.new('tmp') command = option_string() + "mb " + bucket.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#mv(src_bucket, dest_bucket) ⇒ Object
Make a copy of a file (cp) or move a file (mv). Destination can be in the same bucket with a dif‐ ferent name or in another bucket with the same or different name. Adding –acl-public will make the destination object publicly accessible (see below).
519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 519 def mv(src_bucket, dest_bucket) # s3://BUCKET1/OBJECT1 s3://BUCKET2[/OBJECT2] tmp = Tempfile.new('tmp') command = option_string() + "mv " + src_bucket.to_s + " " + dest_bucket.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#put(files, bucket) ⇒ Object
Put file into bucket (i.e. upload to S3)
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 409 def put(files, bucket) # FILE [FILE...] s3://BUCKET[/PREFIX] tmp = Tempfile.new('tmp') command = option_string() + "put " + files.to_s + " " + bucket.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#rb(bucket) ⇒ Object
Remove bucket
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 346 def rb(bucket) # s3://BUCKET tmp = Tempfile.new('tmp') command = option_string() + "rb " + bucket.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#setacl(bucket) ⇒ Object
Modify Access control list for Bucket or Files. Use with –acl-public or –acl-private
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 540 def setacl(bucket) # s3://BUCKET[/OBJECT] tmp = Tempfile.new('tmp') command = option_string() + "setacl " + bucket.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#show_config ⇒ Object
709 710 711 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 709 def show_config option_string() end |
#sync(src_object, dest_object) ⇒ Object
Backup a directory tree to S3 Restore a tree from S3 to local directory
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 473 def sync(src_object, dest_object) # LOCAL_DIR s3://BUCKET[/PREFIX] or s3://BUCKET[/PREFIX] LOCAL_DIR tmp = Tempfile.new('tmp') command = option_string() + "sync " + src_object.to_s + " " + dest_object.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#version ⇒ Object
Show s3cmd version and exit.
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 257 def version tmp = Tempfile.new('tmp') command = option_string() + "--version " + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |