aws-sdk 1.8.5 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.yardopts +1 -0
- data/README.rdoc +8 -0
- data/lib/aws-sdk.rb +39 -35
- data/lib/aws/api_config/CloudFront-2012-07-01.yml +2398 -0
- data/lib/aws/api_config/DirectConnect-2012-10-25.yml +475 -0
- data/lib/aws/api_config/DynamoDB-2011-12-05.yml +8 -0
- data/lib/aws/api_config/DynamoDB-2012-08-10.yml +1516 -0
- data/lib/aws/api_config/OpsWorks-2013-02-18.yml +2 -2
- data/lib/aws/auto_scaling.rb +44 -44
- data/lib/aws/auto_scaling/activity.rb +1 -1
- data/lib/aws/auto_scaling/activity_collection.rb +14 -15
- data/lib/aws/auto_scaling/client.rb +277 -277
- data/lib/aws/auto_scaling/config.rb +1 -1
- data/lib/aws/auto_scaling/group.rb +35 -36
- data/lib/aws/auto_scaling/group_collection.rb +10 -10
- data/lib/aws/auto_scaling/group_options.rb +19 -19
- data/lib/aws/auto_scaling/instance.rb +27 -27
- data/lib/aws/auto_scaling/instance_collection.rb +10 -10
- data/lib/aws/auto_scaling/launch_configuration.rb +3 -3
- data/lib/aws/auto_scaling/launch_configuration_collection.rb +1 -1
- data/lib/aws/auto_scaling/notification_configuration.rb +2 -2
- data/lib/aws/auto_scaling/notification_configuration_collection.rb +37 -38
- data/lib/aws/auto_scaling/scaling_policy.rb +3 -3
- data/lib/aws/auto_scaling/scaling_policy_collection.rb +6 -6
- data/lib/aws/auto_scaling/scaling_policy_options.rb +8 -7
- data/lib/aws/auto_scaling/scheduled_action.rb +3 -3
- data/lib/aws/auto_scaling/scheduled_action_collection.rb +28 -28
- data/lib/aws/auto_scaling/tag_collection.rb +30 -28
- data/lib/aws/cloud_formation.rb +95 -94
- data/lib/aws/cloud_formation/client.rb +136 -133
- data/lib/aws/cloud_formation/config.rb +1 -1
- data/lib/aws/cloud_formation/stack.rb +37 -37
- data/lib/aws/cloud_formation/stack_collection.rb +28 -27
- data/lib/aws/cloud_formation/stack_event.rb +9 -11
- data/lib/aws/cloud_formation/stack_output.rb +1 -1
- data/lib/aws/cloud_formation/stack_resource.rb +6 -6
- data/lib/aws/cloud_formation/stack_resource_collection.rb +11 -12
- data/lib/aws/cloud_formation/stack_resource_summary_collection.rb +11 -11
- data/lib/aws/cloud_formation/stack_summary_collection.rb +39 -39
- data/lib/aws/cloud_front.rb +21 -21
- data/lib/aws/cloud_front/client.rb +853 -652
- data/lib/aws/cloud_front/request.rb +3 -0
- data/lib/aws/cloud_search.rb +22 -22
- data/lib/aws/cloud_search/client.rb +322 -315
- data/lib/aws/cloud_search/config.rb +1 -1
- data/lib/aws/cloud_watch.rb +39 -39
- data/lib/aws/cloud_watch/alarm.rb +55 -37
- data/lib/aws/cloud_watch/alarm_collection.rb +18 -18
- data/lib/aws/cloud_watch/alarm_history_item_collection.rb +2 -2
- data/lib/aws/cloud_watch/client.rb +360 -146
- data/lib/aws/cloud_watch/config.rb +1 -1
- data/lib/aws/cloud_watch/metric.rb +15 -15
- data/lib/aws/cloud_watch/metric_alarm_collection.rb +17 -17
- data/lib/aws/cloud_watch/metric_collection.rb +16 -16
- data/lib/aws/cloud_watch/metric_statistics.rb +11 -11
- data/lib/aws/core.rb +243 -225
- data/lib/aws/core/async_handle.rb +13 -13
- data/lib/aws/core/cacheable.rb +14 -15
- data/lib/aws/core/client.rb +40 -15
- data/lib/aws/core/collection.rb +42 -46
- data/lib/aws/core/collection/with_limit_and_next_token.rb +1 -1
- data/lib/aws/core/collection/with_next_token.rb +1 -1
- data/lib/aws/core/configuration.rb +97 -133
- data/lib/aws/core/credential_providers.rb +16 -16
- data/lib/aws/core/data.rb +23 -23
- data/lib/aws/core/http/connection_pool.rb +348 -0
- data/lib/aws/core/http/net_http_handler.rb +17 -26
- data/lib/aws/core/http/patch.rb +102 -0
- data/lib/aws/core/http/request.rb +13 -19
- data/lib/aws/core/http/response.rb +2 -2
- data/lib/aws/core/lazy_error_classes.rb +17 -17
- data/lib/aws/core/log_formatter.rb +70 -104
- data/lib/aws/core/options/json_serializer.rb +1 -1
- data/lib/aws/core/options/validator.rb +4 -4
- data/lib/aws/core/page_result.rb +8 -8
- data/lib/aws/core/policy.rb +49 -49
- data/lib/aws/core/region.rb +72 -0
- data/lib/aws/core/region_collection.rb +106 -0
- data/lib/aws/core/resource.rb +5 -5
- data/lib/aws/core/response.rb +20 -17
- data/lib/aws/core/rest_request_builder.rb +4 -4
- data/lib/aws/core/service_interface.rb +24 -2
- data/lib/aws/core/signature/version_3.rb +2 -2
- data/lib/aws/core/uri_escape.rb +1 -1
- data/lib/aws/core/xml/frame_stack.rb +1 -1
- data/lib/aws/core/xml/grammar.rb +3 -4
- data/lib/aws/core/xml/sax_handlers/libxml.rb +2 -2
- data/lib/aws/core/xml/sax_handlers/nokogiri.rb +3 -3
- data/lib/aws/core/xml/sax_handlers/rexml.rb +5 -5
- data/lib/aws/core/xml/stub.rb +9 -9
- data/lib/aws/data_pipeline.rb +21 -21
- data/lib/aws/data_pipeline/client.rb +189 -133
- data/lib/aws/data_pipeline/config.rb +1 -1
- data/lib/aws/direct_connect.rb +74 -0
- data/lib/aws/direct_connect/client.rb +253 -0
- data/lib/aws/direct_connect/config.rb +18 -0
- data/lib/aws/direct_connect/errors.rb +22 -0
- data/lib/aws/direct_connect/request.rb +27 -0
- data/lib/aws/dynamo_db.rb +71 -69
- data/lib/aws/dynamo_db/attribute_collection.rb +53 -58
- data/lib/aws/dynamo_db/batch_get.rb +23 -23
- data/lib/aws/dynamo_db/batch_write.rb +43 -43
- data/lib/aws/dynamo_db/binary.rb +9 -9
- data/lib/aws/dynamo_db/client.rb +494 -509
- data/lib/aws/dynamo_db/client_base.rb +91 -0
- data/lib/aws/dynamo_db/client_v2.rb +825 -0
- data/lib/aws/dynamo_db/config.rb +1 -1
- data/lib/aws/dynamo_db/item.rb +10 -10
- data/lib/aws/dynamo_db/item_collection.rb +75 -75
- data/lib/aws/dynamo_db/table.rb +85 -85
- data/lib/aws/dynamo_db/table_collection.rb +13 -13
- data/lib/aws/ec2.rb +132 -142
- data/lib/aws/ec2/attachment.rb +31 -36
- data/lib/aws/ec2/attachment_collection.rb +1 -1
- data/lib/aws/ec2/availability_zone.rb +4 -4
- data/lib/aws/ec2/client.rb +2272 -2125
- data/lib/aws/ec2/config.rb +1 -1
- data/lib/aws/ec2/customer_gateway.rb +6 -6
- data/lib/aws/ec2/customer_gateway_collection.rb +6 -6
- data/lib/aws/ec2/dhcp_options.rb +3 -3
- data/lib/aws/ec2/dhcp_options_collection.rb +10 -10
- data/lib/aws/ec2/elastic_ip.rb +15 -15
- data/lib/aws/ec2/elastic_ip_collection.rb +11 -15
- data/lib/aws/ec2/export_task.rb +4 -4
- data/lib/aws/ec2/export_task_collection.rb +11 -11
- data/lib/aws/ec2/filtered_collection.rb +6 -8
- data/lib/aws/ec2/image.rb +46 -40
- data/lib/aws/ec2/image_collection.rb +44 -52
- data/lib/aws/ec2/instance.rb +64 -62
- data/lib/aws/ec2/instance_collection.rb +47 -50
- data/lib/aws/ec2/internet_gateway.rb +6 -6
- data/lib/aws/ec2/internet_gateway/attachment.rb +13 -13
- data/lib/aws/ec2/internet_gateway_collection.rb +3 -3
- data/lib/aws/ec2/key_pair.rb +3 -3
- data/lib/aws/ec2/key_pair_collection.rb +12 -12
- data/lib/aws/ec2/network_acl.rb +39 -39
- data/lib/aws/ec2/network_acl/association.rb +2 -2
- data/lib/aws/ec2/network_acl/entry.rb +22 -22
- data/lib/aws/ec2/network_acl_collection.rb +2 -2
- data/lib/aws/ec2/network_interface.rb +13 -4
- data/lib/aws/ec2/network_interface/attachment.rb +3 -3
- data/lib/aws/ec2/network_interface_collection.rb +5 -5
- data/lib/aws/ec2/permission_collection.rb +1 -1
- data/lib/aws/ec2/region.rb +6 -6
- data/lib/aws/ec2/region_collection.rb +1 -1
- data/lib/aws/ec2/reserved_instances_collection.rb +2 -2
- data/lib/aws/ec2/reserved_instances_offering_collection.rb +2 -2
- data/lib/aws/ec2/resource_tag_collection.rb +5 -5
- data/lib/aws/ec2/route_table.rb +14 -14
- data/lib/aws/ec2/route_table/association.rb +22 -22
- data/lib/aws/ec2/route_table/route.rb +8 -8
- data/lib/aws/ec2/route_table_collection.rb +3 -3
- data/lib/aws/ec2/security_group.rb +39 -41
- data/lib/aws/ec2/security_group_collection.rb +19 -21
- data/lib/aws/ec2/snapshot.rb +3 -3
- data/lib/aws/ec2/snapshot_collection.rb +11 -12
- data/lib/aws/ec2/subnet.rb +2 -2
- data/lib/aws/ec2/subnet_collection.rb +17 -17
- data/lib/aws/ec2/tag_collection.rb +1 -1
- data/lib/aws/ec2/tagged_collection.rb +7 -7
- data/lib/aws/ec2/tagged_item.rb +10 -10
- data/lib/aws/ec2/volume.rb +16 -16
- data/lib/aws/ec2/volume_collection.rb +9 -12
- data/lib/aws/ec2/vpc.rb +6 -6
- data/lib/aws/ec2/vpc_collection.rb +10 -10
- data/lib/aws/ec2/vpn_connection.rb +4 -4
- data/lib/aws/ec2/vpn_connection/telemetry.rb +1 -1
- data/lib/aws/ec2/vpn_connection_collection.rb +6 -6
- data/lib/aws/ec2/vpn_gateway.rb +2 -2
- data/lib/aws/ec2/vpn_gateway_collection.rb +5 -5
- data/lib/aws/elastic_beanstalk.rb +12 -12
- data/lib/aws/elastic_beanstalk/client.rb +376 -368
- data/lib/aws/elastic_beanstalk/config.rb +1 -1
- data/lib/aws/elastic_transcoder.rb +5 -5
- data/lib/aws/elastic_transcoder/client.rb +283 -283
- data/lib/aws/elastic_transcoder/config.rb +1 -1
- data/lib/aws/elasticache.rb +12 -12
- data/lib/aws/elasticache/client.rb +484 -479
- data/lib/aws/elasticache/config.rb +1 -1
- data/lib/aws/elb.rb +23 -23
- data/lib/aws/elb/availability_zone_collection.rb +34 -34
- data/lib/aws/elb/backend_server_policy_collection.rb +24 -24
- data/lib/aws/elb/client.rb +153 -153
- data/lib/aws/elb/config.rb +1 -1
- data/lib/aws/elb/errors.rb +1 -1
- data/lib/aws/elb/instance_collection.rb +20 -25
- data/lib/aws/elb/listener.rb +3 -3
- data/lib/aws/elb/listener_collection.rb +8 -8
- data/lib/aws/elb/load_balancer.rb +15 -16
- data/lib/aws/elb/load_balancer_collection.rb +36 -24
- data/lib/aws/elb/load_balancer_policy.rb +1 -1
- data/lib/aws/elb/load_balancer_policy_collection.rb +5 -5
- data/lib/aws/emr.rb +28 -26
- data/lib/aws/emr/client.rb +165 -149
- data/lib/aws/emr/config.rb +1 -1
- data/lib/aws/emr/instance_group.rb +1 -1
- data/lib/aws/emr/instance_group_collection.rb +1 -1
- data/lib/aws/emr/job_flow.rb +27 -26
- data/lib/aws/emr/job_flow_collection.rb +34 -34
- data/lib/aws/errors.rb +7 -7
- data/lib/aws/glacier.rb +21 -21
- data/lib/aws/glacier/archive_collection.rb +2 -2
- data/lib/aws/glacier/client.rb +139 -140
- data/lib/aws/glacier/config.rb +1 -1
- data/lib/aws/glacier/vault.rb +2 -2
- data/lib/aws/glacier/vault_collection.rb +1 -1
- data/lib/aws/iam.rb +133 -144
- data/lib/aws/iam/access_key.rb +17 -17
- data/lib/aws/iam/access_key_collection.rb +22 -22
- data/lib/aws/iam/account_alias_collection.rb +2 -2
- data/lib/aws/iam/client.rb +429 -420
- data/lib/aws/iam/collection.rb +1 -1
- data/lib/aws/iam/config.rb +2 -2
- data/lib/aws/iam/group.rb +8 -8
- data/lib/aws/iam/group_collection.rb +16 -16
- data/lib/aws/iam/group_policy_collection.rb +6 -6
- data/lib/aws/iam/group_user_collection.rb +3 -3
- data/lib/aws/iam/mfa_device.rb +1 -1
- data/lib/aws/iam/mfa_device_collection.rb +9 -9
- data/lib/aws/iam/policy_collection.rb +4 -4
- data/lib/aws/iam/resource.rb +2 -2
- data/lib/aws/iam/server_certificate.rb +1 -1
- data/lib/aws/iam/server_certificate_collection.rb +15 -15
- data/lib/aws/iam/signing_certificate.rb +29 -29
- data/lib/aws/iam/signing_certificate_collection.rb +23 -23
- data/lib/aws/iam/user.rb +33 -38
- data/lib/aws/iam/user_collection.rb +27 -27
- data/lib/aws/iam/user_group_collection.rb +3 -3
- data/lib/aws/iam/user_policy_collection.rb +6 -6
- data/lib/aws/iam/virtual_mfa_device.rb +12 -12
- data/lib/aws/iam/virtual_mfa_device_collection.rb +4 -4
- data/lib/aws/import_export.rb +22 -21
- data/lib/aws/import_export/client.rb +47 -43
- data/lib/aws/ops_works.rb +5 -5
- data/lib/aws/ops_works/client.rb +484 -438
- data/lib/aws/ops_works/config.rb +1 -1
- data/lib/aws/rails.rb +34 -34
- data/lib/aws/rds.rb +18 -18
- data/lib/aws/rds/client.rb +1286 -1277
- data/lib/aws/rds/config.rb +1 -1
- data/lib/aws/rds/db_instance.rb +15 -4
- data/lib/aws/rds/db_snapshot.rb +1 -1
- data/lib/aws/record.rb +50 -24
- data/lib/aws/record/abstract_base.rb +52 -60
- data/lib/aws/record/attributes.rb +79 -79
- data/lib/aws/record/conversion.rb +1 -1
- data/lib/aws/record/dirty_tracking.rb +69 -67
- data/lib/aws/record/errors.rb +21 -21
- data/lib/aws/record/exceptions.rb +2 -2
- data/lib/aws/record/hash_model.rb +20 -21
- data/lib/aws/record/hash_model/attributes.rb +13 -15
- data/lib/aws/record/hash_model/finder_methods.rb +46 -46
- data/lib/aws/record/hash_model/scope.rb +31 -31
- data/lib/aws/record/model.rb +136 -136
- data/lib/aws/record/model/attributes.rb +57 -59
- data/lib/aws/record/model/finder_methods.rb +67 -67
- data/lib/aws/record/model/scope.rb +48 -49
- data/lib/aws/record/naming.rb +1 -1
- data/lib/aws/record/scope.rb +23 -19
- data/lib/aws/record/validations.rb +253 -271
- data/lib/aws/record/validator.rb +3 -3
- data/lib/aws/record/validators/acceptance.rb +1 -3
- data/lib/aws/record/validators/block.rb +1 -3
- data/lib/aws/record/validators/confirmation.rb +1 -3
- data/lib/aws/record/validators/count.rb +2 -4
- data/lib/aws/record/validators/exclusion.rb +2 -4
- data/lib/aws/record/validators/format.rb +2 -4
- data/lib/aws/record/validators/inclusion.rb +1 -3
- data/lib/aws/record/validators/length.rb +5 -7
- data/lib/aws/record/validators/method.rb +1 -3
- data/lib/aws/record/validators/numericality.rb +6 -8
- data/lib/aws/record/validators/presence.rb +1 -3
- data/lib/aws/redshift.rb +14 -14
- data/lib/aws/redshift/client.rb +596 -592
- data/lib/aws/redshift/config.rb +1 -1
- data/lib/aws/route_53.rb +30 -30
- data/lib/aws/route_53/change_batch.rb +7 -7
- data/lib/aws/route_53/client.rb +188 -152
- data/lib/aws/route_53/hosted_zone.rb +4 -4
- data/lib/aws/route_53/hosted_zone_collection.rb +7 -7
- data/lib/aws/route_53/resource_record_set.rb +10 -10
- data/lib/aws/route_53/resource_record_set_collection.rb +6 -6
- data/lib/aws/s3.rb +79 -79
- data/lib/aws/s3/access_control_list.rb +44 -36
- data/lib/aws/s3/acl_options.rb +51 -51
- data/lib/aws/s3/bucket.rb +146 -146
- data/lib/aws/s3/bucket_collection.rb +21 -21
- data/lib/aws/s3/bucket_lifecycle_configuration.rb +81 -82
- data/lib/aws/s3/bucket_tag_collection.rb +4 -2
- data/lib/aws/s3/cipher_io.rb +5 -4
- data/lib/aws/s3/client.rb +89 -84
- data/lib/aws/s3/client/xml.rb +1 -1
- data/lib/aws/s3/config.rb +7 -1
- data/lib/aws/s3/cors_rule.rb +2 -0
- data/lib/aws/s3/cors_rule_collection.rb +42 -40
- data/lib/aws/s3/data_options.rb +16 -11
- data/lib/aws/s3/encryption_utils.rb +2 -2
- data/lib/aws/s3/errors.rb +7 -7
- data/lib/aws/s3/multipart_upload.rb +30 -33
- data/lib/aws/s3/multipart_upload_collection.rb +8 -6
- data/lib/aws/s3/object_collection.rb +35 -35
- data/lib/aws/s3/object_metadata.rb +6 -6
- data/lib/aws/s3/object_version.rb +4 -4
- data/lib/aws/s3/object_version_collection.rb +15 -15
- data/lib/aws/s3/policy.rb +2 -2
- data/lib/aws/s3/prefixed_collection.rb +9 -5
- data/lib/aws/s3/presigned_post.rb +39 -37
- data/lib/aws/s3/request.rb +11 -11
- data/lib/aws/s3/s3_object.rb +210 -200
- data/lib/aws/s3/tree.rb +25 -27
- data/lib/aws/s3/tree/child_collection.rb +3 -3
- data/lib/aws/s3/tree/leaf_node.rb +2 -2
- data/lib/aws/s3/tree/parent.rb +1 -1
- data/lib/aws/s3/website_configuration.rb +13 -13
- data/lib/aws/simple_db.rb +83 -83
- data/lib/aws/simple_db/attribute.rb +9 -7
- data/lib/aws/simple_db/attribute_collection.rb +22 -13
- data/lib/aws/simple_db/client.rb +107 -107
- data/lib/aws/simple_db/config.rb +7 -1
- data/lib/aws/simple_db/consistent_read_option.rb +5 -5
- data/lib/aws/simple_db/domain.rb +4 -2
- data/lib/aws/simple_db/domain_collection.rb +4 -4
- data/lib/aws/simple_db/domain_metadata.rb +5 -5
- data/lib/aws/simple_db/errors.rb +9 -9
- data/lib/aws/simple_db/item.rb +5 -5
- data/lib/aws/simple_db/item_collection.rb +83 -81
- data/lib/aws/simple_db/item_data.rb +4 -4
- data/lib/aws/simple_db/put_attributes.rb +3 -3
- data/lib/aws/simple_email_service.rb +140 -140
- data/lib/aws/simple_email_service/client.rb +82 -76
- data/lib/aws/simple_email_service/config.rb +1 -2
- data/lib/aws/simple_email_service/email_address_collection.rb +3 -3
- data/lib/aws/simple_email_service/identity.rb +8 -8
- data/lib/aws/simple_email_service/quotas.rb +8 -6
- data/lib/aws/simple_workflow.rb +106 -106
- data/lib/aws/simple_workflow/activity_task.rb +15 -22
- data/lib/aws/simple_workflow/activity_task_collection.rb +15 -15
- data/lib/aws/simple_workflow/activity_type.rb +23 -23
- data/lib/aws/simple_workflow/activity_type_collection.rb +23 -23
- data/lib/aws/simple_workflow/client.rb +1004 -956
- data/lib/aws/simple_workflow/config.rb +1 -1
- data/lib/aws/simple_workflow/count.rb +5 -5
- data/lib/aws/simple_workflow/decision_task.rb +129 -129
- data/lib/aws/simple_workflow/decision_task_collection.rb +59 -59
- data/lib/aws/simple_workflow/domain.rb +11 -11
- data/lib/aws/simple_workflow/domain_collection.rb +26 -26
- data/lib/aws/simple_workflow/history_event.rb +32 -32
- data/lib/aws/simple_workflow/history_event_collection.rb +3 -3
- data/lib/aws/simple_workflow/option_formatters.rb +5 -5
- data/lib/aws/simple_workflow/request.rb +1 -1
- data/lib/aws/simple_workflow/resource.rb +1 -1
- data/lib/aws/simple_workflow/type.rb +8 -8
- data/lib/aws/simple_workflow/type_collection.rb +15 -15
- data/lib/aws/simple_workflow/workflow_execution.rb +70 -72
- data/lib/aws/simple_workflow/workflow_execution_collection.rb +130 -130
- data/lib/aws/simple_workflow/workflow_type.rb +27 -25
- data/lib/aws/simple_workflow/workflow_type_collection.rb +20 -20
- data/lib/aws/sns.rb +25 -25
- data/lib/aws/sns/client.rb +55 -55
- data/lib/aws/sns/config.rb +1 -1
- data/lib/aws/sns/policy.rb +1 -1
- data/lib/aws/sns/subscription.rb +7 -7
- data/lib/aws/sns/subscription_collection.rb +5 -5
- data/lib/aws/sns/topic.rb +49 -49
- data/lib/aws/sns/topic_collection.rb +2 -2
- data/lib/aws/sns/topic_subscription_collection.rb +5 -5
- data/lib/aws/sqs.rb +20 -20
- data/lib/aws/sqs/client.rb +78 -78
- data/lib/aws/sqs/config.rb +1 -1
- data/lib/aws/sqs/errors.rb +12 -12
- data/lib/aws/sqs/queue.rb +66 -67
- data/lib/aws/sqs/queue_collection.rb +16 -8
- data/lib/aws/sqs/received_message.rb +7 -6
- data/lib/aws/storage_gateway.rb +21 -21
- data/lib/aws/storage_gateway/client.rb +269 -202
- data/lib/aws/storage_gateway/config.rb +1 -1
- data/lib/aws/sts.rb +10 -8
- data/lib/aws/sts/client.rb +35 -35
- data/lib/aws/sts/session.rb +3 -3
- data/lib/aws/version.rb +1 -2
- metadata +23 -21
- data/lib/aws/core/autoloader.rb +0 -64
- data/lib/net/http/connection_pool.rb +0 -226
- data/lib/net/http/connection_pool/connection.rb +0 -189
- data/lib/net/http/connection_pool/session.rb +0 -126
|
@@ -35,8 +35,8 @@ module AWS
|
|
|
35
35
|
# Returns the value for the given name stored in the S3Object's
|
|
36
36
|
# metadata:
|
|
37
37
|
#
|
|
38
|
-
#
|
|
39
|
-
#
|
|
38
|
+
# bucket.objects['myobject'].metadata['purpose']
|
|
39
|
+
# # returns nil if the given metadata key has not been set
|
|
40
40
|
#
|
|
41
41
|
# @param [String,Symbol] name The name of the metadata field to
|
|
42
42
|
# get.
|
|
@@ -49,9 +49,9 @@ module AWS
|
|
|
49
49
|
# Changes the value of the given name stored in the S3Object's
|
|
50
50
|
# metadata:
|
|
51
51
|
#
|
|
52
|
-
#
|
|
53
|
-
#
|
|
54
|
-
#
|
|
52
|
+
# object = bucket.object['myobject']
|
|
53
|
+
# object.metadata['purpose'] = 'research'
|
|
54
|
+
# object.metadata['purpose'] # => 'research'
|
|
55
55
|
#
|
|
56
56
|
# @note The name and value of each metadata field must conform
|
|
57
57
|
# to US-ASCII.
|
|
@@ -80,7 +80,7 @@ module AWS
|
|
|
80
80
|
self[name]
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
# @return [Hash] Returns the user-generated metadata stored with
|
|
83
|
+
# @return [Hash] Returns the user-generated metadata stored with
|
|
84
84
|
# this S3 Object.
|
|
85
85
|
def to_h
|
|
86
86
|
options = {}
|
|
@@ -16,8 +16,8 @@ module AWS
|
|
|
16
16
|
|
|
17
17
|
# Represents a single version of an S3Object.
|
|
18
18
|
#
|
|
19
|
-
# When you enable versioning on a S3 bucket, writing to an object
|
|
20
|
-
# will create an object version instead of replacing the existing
|
|
19
|
+
# When you enable versioning on a S3 bucket, writing to an object
|
|
20
|
+
# will create an object version instead of replacing the existing
|
|
21
21
|
# object.
|
|
22
22
|
class ObjectVersion
|
|
23
23
|
|
|
@@ -112,14 +112,14 @@ module AWS
|
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
# If you delete an object in a versioned bucket, a delete marker
|
|
115
|
-
# is created.
|
|
115
|
+
# is created.
|
|
116
116
|
# @return [Boolean] Returns true if this version is a delete marker.
|
|
117
117
|
def delete_marker?
|
|
118
118
|
if @delete_marker.nil?
|
|
119
119
|
begin
|
|
120
120
|
# S3 responds with a 405 (method not allowed) when you try
|
|
121
121
|
# to HEAD an s3 object version that is a delete marker
|
|
122
|
-
metadata['foo']
|
|
122
|
+
metadata['foo']
|
|
123
123
|
@delete_marker = false
|
|
124
124
|
rescue Errors::MethodNotAllowed => error
|
|
125
125
|
@delete_marker = true
|
|
@@ -17,31 +17,31 @@ module AWS
|
|
|
17
17
|
# For S3 buckets with versioning enabled, objects will store versions
|
|
18
18
|
# each time you write to them.
|
|
19
19
|
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
20
|
+
# object = bucket.objects['myobj']
|
|
21
|
+
# object.write('1')
|
|
22
|
+
# object.write('2')
|
|
23
|
+
# object.write('3')
|
|
24
24
|
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
25
|
+
# object.versions.collect(&:read)
|
|
26
|
+
# #=> ['1', '2', '3']
|
|
27
27
|
#
|
|
28
28
|
# To see all the version id for a particular object, access the any particular version,
|
|
29
29
|
# and see the latest version:
|
|
30
30
|
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
31
|
+
# object.versions.each do |version| puts version.version_id end
|
|
32
|
+
# #=> T2TwAiZ3SmNr7tOfe0QBa4RZnSb3GSLq
|
|
33
|
+
# #=> kAEHC_ysT65bT4P3zyYOP1ELA6ajar_6
|
|
34
|
+
# #=> itHPX6m8na_sog0cAtkgP3QITEE8v5ij
|
|
35
35
|
#
|
|
36
|
-
#
|
|
37
|
-
#
|
|
36
|
+
# object.versions['itHPX6m8na_sog0cAtkgP3QITEE8v5ij']
|
|
37
|
+
# #=> <AWS::S3::ObjectVersion:<<bucket>>:myobj:itHPX6m8na_sog0cAtkgP3QITEE8v5ij>
|
|
38
38
|
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
39
|
+
# object.versions.latest
|
|
40
|
+
# #=> <AWS::S3::ObjectVersion:<<bucket>>:myobj:T2TwAiZ3SmNr7tOfe0QBa4RZnSb3GSLq>
|
|
41
41
|
#
|
|
42
42
|
# If you know the id of a particular version you can get that object.
|
|
43
43
|
#
|
|
44
|
-
#
|
|
44
|
+
# bucket.objects['myobj'].version[version_id].delete
|
|
45
45
|
#
|
|
46
46
|
class ObjectVersionCollection
|
|
47
47
|
|
data/lib/aws/s3/policy.rb
CHANGED
|
@@ -58,11 +58,11 @@ module AWS
|
|
|
58
58
|
"#{prefix}#{resource.name}"
|
|
59
59
|
when S3Object
|
|
60
60
|
"#{prefix}#{resource.bucket.name}/#{resource.key}"
|
|
61
|
-
when ObjectCollection
|
|
61
|
+
when ObjectCollection
|
|
62
62
|
"#{prefix}#{resource.bucket.name}/#{resource.prefix}*"
|
|
63
63
|
when /^arn:/
|
|
64
64
|
resource
|
|
65
|
-
else
|
|
65
|
+
else
|
|
66
66
|
"arn:aws:s3:::#{resource}"
|
|
67
67
|
end
|
|
68
68
|
end
|
|
@@ -25,36 +25,40 @@ module AWS
|
|
|
25
25
|
args.push(options)
|
|
26
26
|
super(*args)
|
|
27
27
|
end
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
# @return [String,nil] The prefix of this collection.
|
|
30
30
|
attr_reader :prefix
|
|
31
31
|
|
|
32
32
|
# Returns a new collection with a different prefix
|
|
33
33
|
#
|
|
34
34
|
# @example
|
|
35
|
+
#
|
|
35
36
|
# objects = collection.with_prefix('photos')
|
|
36
37
|
# objects.prefix #=> 'photos'
|
|
37
38
|
#
|
|
38
39
|
# @example Chaining with_prefix replaces previous prefix
|
|
40
|
+
#
|
|
39
41
|
# objects = collection.with_prefix('photos').with_prefix('videos')
|
|
40
42
|
# objects.prefix #=> 'videos'
|
|
41
43
|
#
|
|
42
44
|
# @example Chaining with_prefix with :append
|
|
45
|
+
#
|
|
43
46
|
# objects = collection.with_prefix('a/').with_prefix('b/', :append)
|
|
44
47
|
# objects.prefix #=> 'a/b/'
|
|
45
48
|
#
|
|
46
49
|
# @example Chaining with_prefix with :prepend
|
|
50
|
+
#
|
|
47
51
|
# objects = collection.with_prefix('a/').with_prefix('b/', :prepend)
|
|
48
52
|
# objects.prefix #=> 'b/a/'
|
|
49
53
|
#
|
|
50
54
|
# @param [String] prefix The prefix condition that limits what objects
|
|
51
55
|
# are returned by this collection.
|
|
52
56
|
# @param [Symbol] mode (:replace) If you chain calls to #with_prefix
|
|
53
|
-
# the
|
|
57
|
+
# the `mode` affects if the prefix prepends, appends, or replaces.
|
|
54
58
|
# Valid modes are:
|
|
55
|
-
# *
|
|
56
|
-
# *
|
|
57
|
-
# *
|
|
59
|
+
# * `:replace`
|
|
60
|
+
# * `:append`
|
|
61
|
+
# * `:prepend`
|
|
58
62
|
# @return [Collection] Returns a new collection with a modified prefix.
|
|
59
63
|
def with_prefix prefix, mode = :replace
|
|
60
64
|
new_prefix = case mode
|
|
@@ -43,9 +43,11 @@ module AWS
|
|
|
43
43
|
# END
|
|
44
44
|
#
|
|
45
45
|
# @example Restricting the size of the uploaded object
|
|
46
|
+
#
|
|
46
47
|
# bucket.presigned_post(:content_length => 1..(10*1024))
|
|
47
48
|
#
|
|
48
49
|
# @example Restricting the key prefix
|
|
50
|
+
#
|
|
49
51
|
# bucket.presigned_post.where(:key).starts_with("photos/")
|
|
50
52
|
#
|
|
51
53
|
class PresignedPost
|
|
@@ -103,7 +105,7 @@ module AWS
|
|
|
103
105
|
# using the form fields.
|
|
104
106
|
#
|
|
105
107
|
# @param [Hash] opts Additional options for the upload. Aside
|
|
106
|
-
# from
|
|
108
|
+
# from `:secure`, `:expires`, `:content_length` and `:ignore`
|
|
107
109
|
# the values provided here will be stored in the hash returned
|
|
108
110
|
# from the {#fields} method, and the policy in that hash will
|
|
109
111
|
# restrict their values to the values provided. If you
|
|
@@ -148,19 +150,19 @@ module AWS
|
|
|
148
150
|
#
|
|
149
151
|
# @option options [Symbol] :acl A canned access control
|
|
150
152
|
# policy. Valid values are:
|
|
151
|
-
# *
|
|
152
|
-
# *
|
|
153
|
-
# *
|
|
154
|
-
# *
|
|
155
|
-
# *
|
|
156
|
-
# *
|
|
153
|
+
# * `:private`
|
|
154
|
+
# * `:public_read`
|
|
155
|
+
# * `:public_read_write`
|
|
156
|
+
# * `:authenticated_read`
|
|
157
|
+
# * `:bucket_owner_read`
|
|
158
|
+
# * `:bucket_owner_full_control`
|
|
157
159
|
#
|
|
158
160
|
# @option options [Symbol] :server_side_encryption (nil) If this
|
|
159
161
|
# option is set, the object will be stored using server side
|
|
160
|
-
# encryption. The only valid value is
|
|
162
|
+
# encryption. The only valid value is `:aes256`, which
|
|
161
163
|
# specifies that the object should be stored using the AES
|
|
162
164
|
# encryption algorithm with 256 bit keys. By default, this
|
|
163
|
-
# option uses the value of the
|
|
165
|
+
# option uses the value of the `:s3_server_side_encryption`
|
|
164
166
|
# option in the current configuration; for more information,
|
|
165
167
|
# see {AWS.config}.
|
|
166
168
|
#
|
|
@@ -169,7 +171,7 @@ module AWS
|
|
|
169
171
|
#
|
|
170
172
|
# @option opts [Integer] :success_action_status The status
|
|
171
173
|
# code returned to the client upon successful upload if
|
|
172
|
-
#
|
|
174
|
+
# `:success_action_redirect` is not specified. Accepts the
|
|
173
175
|
# values 200, 201, or 204 (default).
|
|
174
176
|
#
|
|
175
177
|
# If the value is set to 200 or 204, Amazon S3 returns an
|
|
@@ -178,7 +180,7 @@ module AWS
|
|
|
178
180
|
# If the value is set to 201, Amazon S3 returns an XML
|
|
179
181
|
# document with a 201 status code. For information on the
|
|
180
182
|
# content of the XML document, see
|
|
181
|
-
#
|
|
183
|
+
# [POST Object](http://docs.amazonwebservices.com/AmazonS3/2006-03-01/API/index.html?RESTObjectPOST.html).
|
|
182
184
|
#
|
|
183
185
|
# @option opts [Hash] :metadata A hash of the metadata fields
|
|
184
186
|
# included in the signed fields. Additional metadata fields
|
|
@@ -223,7 +225,7 @@ module AWS
|
|
|
223
225
|
|
|
224
226
|
# @return [URI::HTTP, URI::HTTPS] The URL to which the form
|
|
225
227
|
# fields should be POSTed. If you are using the fields in
|
|
226
|
-
# an HTML form, this is the URL to put in the
|
|
228
|
+
# an HTML form, this is the URL to put in the `action`
|
|
227
229
|
# attribute of the form tag.
|
|
228
230
|
def url
|
|
229
231
|
req = Request.new
|
|
@@ -255,17 +257,17 @@ module AWS
|
|
|
255
257
|
# Specifies that the value of the field must begin with the
|
|
256
258
|
# provided value. If you are specifying a condition on the
|
|
257
259
|
# "key" field, note that this check takes place after the
|
|
258
|
-
#
|
|
260
|
+
# `${filename}` variable is expanded. This is only valid
|
|
259
261
|
# for the following fields:
|
|
260
262
|
#
|
|
261
|
-
# *
|
|
262
|
-
# *
|
|
263
|
-
# *
|
|
264
|
-
# *
|
|
265
|
-
# *
|
|
266
|
-
# *
|
|
267
|
-
# *
|
|
268
|
-
# *
|
|
263
|
+
# * `:key`
|
|
264
|
+
# * `:cache_control`
|
|
265
|
+
# * `:content_type`
|
|
266
|
+
# * `:content_disposition`
|
|
267
|
+
# * `:content_encoding`
|
|
268
|
+
# * `:expires_header`
|
|
269
|
+
# * `:acl`
|
|
270
|
+
# * `:success_action_redirect`
|
|
269
271
|
# * metadata fields (see {#where_metadata})
|
|
270
272
|
def starts_with(prefix)
|
|
271
273
|
@post.with_prefix_condition(@field, prefix)
|
|
@@ -273,8 +275,8 @@ module AWS
|
|
|
273
275
|
|
|
274
276
|
# Specifies that the value of the field must be in the given
|
|
275
277
|
# range. This may only be used to constrain the
|
|
276
|
-
#
|
|
277
|
-
# e.g.
|
|
278
|
+
# `:content_length` field,
|
|
279
|
+
# e.g. `presigned_post.with(:conent_length).in(1..4)`.
|
|
278
280
|
def in(range)
|
|
279
281
|
@post.refine(:content_length => range)
|
|
280
282
|
end
|
|
@@ -290,16 +292,16 @@ module AWS
|
|
|
290
292
|
# @param [Symbol] field The field for which a condition should
|
|
291
293
|
# be added. Valid values:
|
|
292
294
|
#
|
|
293
|
-
# *
|
|
294
|
-
# *
|
|
295
|
-
# *
|
|
296
|
-
# *
|
|
297
|
-
# *
|
|
298
|
-
# *
|
|
299
|
-
# *
|
|
300
|
-
# *
|
|
301
|
-
# *
|
|
302
|
-
# *
|
|
295
|
+
# * `:key`
|
|
296
|
+
# * `:content_length`
|
|
297
|
+
# * `:cache_control`
|
|
298
|
+
# * `:content_type`
|
|
299
|
+
# * `:content_disposition`
|
|
300
|
+
# * `:content_encoding`
|
|
301
|
+
# * `:expires_header`
|
|
302
|
+
# * `:acl`
|
|
303
|
+
# * `:success_action_redirect`
|
|
304
|
+
# * `:success_action_status`
|
|
303
305
|
#
|
|
304
306
|
# @return [ConditionBuilder] An object that allows you to
|
|
305
307
|
# specify a condition on the field.
|
|
@@ -317,7 +319,7 @@ module AWS
|
|
|
317
319
|
# then S3 will reject it.
|
|
318
320
|
#
|
|
319
321
|
# @param [Symbol, String] field The name of the metadata
|
|
320
|
-
# attribute. For example,
|
|
322
|
+
# attribute. For example, `:color` corresponds to the
|
|
321
323
|
# "x-amz-meta-color" field in the POST body.
|
|
322
324
|
#
|
|
323
325
|
# @return [ConditionBuilder] An object that allows you to
|
|
@@ -494,14 +496,14 @@ module AWS
|
|
|
494
496
|
|
|
495
497
|
conditions = self.conditions.inject([]) do |list, (field, field_conds)|
|
|
496
498
|
list + field_conds
|
|
497
|
-
end
|
|
498
|
-
|
|
499
|
+
end
|
|
500
|
+
|
|
499
501
|
conditions << { "bucket" => bucket.name }
|
|
500
502
|
conditions += key_conditions
|
|
501
503
|
conditions += optional_fields.map { |(n, v)| Hash[[[n, v]]] }
|
|
502
504
|
conditions += range_conditions
|
|
503
505
|
conditions += ignored_conditions
|
|
504
|
-
|
|
506
|
+
|
|
505
507
|
if token = config.credential_provider.session_token
|
|
506
508
|
conditions << { "x-amz-security-token" => token }
|
|
507
509
|
end
|
data/lib/aws/s3/request.rb
CHANGED
|
@@ -83,12 +83,12 @@ module AWS
|
|
|
83
83
|
|
|
84
84
|
# From the S3 developer guide:
|
|
85
85
|
#
|
|
86
|
-
#
|
|
87
|
-
#
|
|
88
|
-
#
|
|
89
|
-
#
|
|
90
|
-
#
|
|
91
|
-
#
|
|
86
|
+
# StringToSign =
|
|
87
|
+
# HTTP-Verb ` "\n" `
|
|
88
|
+
# content-md5 ` "\n" `
|
|
89
|
+
# content-type ` "\n" `
|
|
90
|
+
# date ` "\n" `
|
|
91
|
+
# CanonicalizedAmzHeaders + CanonicalizedResource;
|
|
92
92
|
#
|
|
93
93
|
def string_to_sign
|
|
94
94
|
[
|
|
@@ -112,11 +112,11 @@ module AWS
|
|
|
112
112
|
|
|
113
113
|
# From the S3 developer guide
|
|
114
114
|
#
|
|
115
|
-
#
|
|
116
|
-
#
|
|
117
|
-
#
|
|
118
|
-
#
|
|
119
|
-
#
|
|
115
|
+
# CanonicalizedResource =
|
|
116
|
+
# [ "/" ` Bucket ] `
|
|
117
|
+
# <HTTP-Request-URI, from the protocol name up to the querystring> +
|
|
118
|
+
# [ sub-resource, if present. e.g. "?acl", "?location",
|
|
119
|
+
# "?logging", or "?torrent"];
|
|
120
120
|
#
|
|
121
121
|
def canonicalized_resource
|
|
122
122
|
|
data/lib/aws/s3/s3_object.rb
CHANGED
|
@@ -20,57 +20,57 @@ module AWS
|
|
|
20
20
|
# Represents an object in S3. Objects live in a bucket and have
|
|
21
21
|
# unique keys.
|
|
22
22
|
#
|
|
23
|
-
#
|
|
23
|
+
# # Getting Objects
|
|
24
24
|
#
|
|
25
25
|
# You can get an object by its key.
|
|
26
26
|
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
27
|
+
# s3 = AWS::S3.new
|
|
28
|
+
# obj = s3.buckets['my-bucket'].objects['key'] # no request made
|
|
29
29
|
#
|
|
30
30
|
# You can also get objects by enumerating a objects in a bucket.
|
|
31
31
|
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
32
|
+
# bucket.objects.each do |obj|
|
|
33
|
+
# puts obj.key
|
|
34
|
+
# end
|
|
35
35
|
#
|
|
36
36
|
# See {ObjectCollection} for more information on finding objects.
|
|
37
37
|
#
|
|
38
|
-
#
|
|
38
|
+
# # Creating Objects
|
|
39
39
|
#
|
|
40
40
|
# You create an object by writing to it. The following two
|
|
41
41
|
# expressions are equivalent.
|
|
42
42
|
#
|
|
43
|
-
#
|
|
44
|
-
#
|
|
43
|
+
# obj = bucket.objects.create('key', 'data')
|
|
44
|
+
# obj = bucket.objects['key'].write('data')
|
|
45
45
|
#
|
|
46
|
-
#
|
|
46
|
+
# # Writing Objects
|
|
47
47
|
#
|
|
48
48
|
# To upload data to S3, you simply need to call {#write} on an object.
|
|
49
49
|
#
|
|
50
|
-
#
|
|
51
|
-
#
|
|
52
|
-
#
|
|
50
|
+
# obj.write('Hello World!')
|
|
51
|
+
# obj.read
|
|
52
|
+
# #=> 'Hello World!'
|
|
53
53
|
#
|
|
54
|
-
#
|
|
54
|
+
# ## Uploading Files
|
|
55
55
|
#
|
|
56
56
|
# You can upload a file to S3 in a variety of ways. Given a path
|
|
57
57
|
# to a file (as a string) you can do any of the following:
|
|
58
58
|
#
|
|
59
|
-
#
|
|
60
|
-
#
|
|
59
|
+
# # specify the data as a path to a file
|
|
60
|
+
# obj.write(Pathname.new(path_to_file))
|
|
61
61
|
#
|
|
62
|
-
#
|
|
63
|
-
#
|
|
62
|
+
# # also works this way
|
|
63
|
+
# obj.write(:file => path_to_file)
|
|
64
64
|
#
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
-
#
|
|
65
|
+
# # Also accepts an open file object
|
|
66
|
+
# file = File.open(path_to_file, 'r')
|
|
67
|
+
# obj.write(file)
|
|
68
68
|
#
|
|
69
69
|
# All three examples above produce the same result. The file
|
|
70
70
|
# will be streamed to S3 in chunks. It will not be loaded
|
|
71
71
|
# entirely into memory.
|
|
72
72
|
#
|
|
73
|
-
#
|
|
73
|
+
# ## Streaming Uploads
|
|
74
74
|
#
|
|
75
75
|
# When you call {#write} with any IO-like object (must respond to
|
|
76
76
|
# #read and #eof?), it will be streamed to S3 in chunks.
|
|
@@ -78,160 +78,160 @@ module AWS
|
|
|
78
78
|
# While it is possible to determine the size of many IO objects, you may
|
|
79
79
|
# have to specify the :content_length of your IO object.
|
|
80
80
|
# If the exact size can not be known, you may provide an
|
|
81
|
-
#
|
|
81
|
+
# `:estimated_content_length`. Depending on the size (actual or
|
|
82
82
|
# estimated) of your data, it will be uploaded in a single request or
|
|
83
83
|
# in multiple requests via {#multipart_upload}.
|
|
84
84
|
#
|
|
85
85
|
# You may also stream uploads to S3 using a block:
|
|
86
86
|
#
|
|
87
|
-
#
|
|
88
|
-
#
|
|
89
|
-
#
|
|
90
|
-
#
|
|
87
|
+
# obj.write do |buffer, bytes|
|
|
88
|
+
# # writing fewer than the requested number of bytes to the buffer
|
|
89
|
+
# # will cause write to stop yielding to the block
|
|
90
|
+
# end
|
|
91
91
|
#
|
|
92
|
-
#
|
|
92
|
+
# # Reading Objects
|
|
93
93
|
#
|
|
94
94
|
# You can read an object directly using {#read}. Be warned, this will
|
|
95
95
|
# load the entire object into memory and is not recommended for large
|
|
96
96
|
# objects.
|
|
97
97
|
#
|
|
98
|
-
#
|
|
99
|
-
#
|
|
100
|
-
#
|
|
98
|
+
# obj.write('abc')
|
|
99
|
+
# puts obj.read
|
|
100
|
+
# #=> abc
|
|
101
101
|
#
|
|
102
|
-
#
|
|
102
|
+
# ## Streaming Downloads
|
|
103
103
|
#
|
|
104
104
|
# If you want to stream an object from S3, you can pass a block
|
|
105
105
|
# to {#read}.
|
|
106
106
|
#
|
|
107
|
-
#
|
|
108
|
-
#
|
|
109
|
-
#
|
|
107
|
+
# File.open('output', 'w') do |file|
|
|
108
|
+
# large_object.read do |chunk|
|
|
109
|
+
# file.write(chunk)
|
|
110
|
+
# end
|
|
110
111
|
# end
|
|
111
|
-
# end
|
|
112
112
|
#
|
|
113
|
-
#
|
|
113
|
+
# # Encryption
|
|
114
114
|
#
|
|
115
115
|
# Amazon S3 can encrypt objects for you service-side. You can also
|
|
116
116
|
# use client-side encryption.
|
|
117
117
|
#
|
|
118
|
-
#
|
|
118
|
+
# ## Server Side Encryption
|
|
119
119
|
#
|
|
120
120
|
# Amazon S3 provides server side encryption for an additional cost.
|
|
121
121
|
# You can specify to use server side encryption when writing an object.
|
|
122
122
|
#
|
|
123
|
-
#
|
|
123
|
+
# obj.write('data', :server_side_encryption => :aes256)
|
|
124
124
|
#
|
|
125
125
|
# You can also make this the default behavior.
|
|
126
126
|
#
|
|
127
|
-
#
|
|
127
|
+
# AWS.config(:s3_server_side_encryption => :aes256)
|
|
128
128
|
#
|
|
129
|
-
#
|
|
130
|
-
#
|
|
129
|
+
# s3 = AWS::S3.new
|
|
130
|
+
# s3.buckets['name'].objects['key'].write('abc') # will be encrypted
|
|
131
131
|
#
|
|
132
|
-
#
|
|
132
|
+
# ## Client Side Encryption
|
|
133
133
|
#
|
|
134
134
|
# Client side encryption utilizes envelope encryption, so that your keys are
|
|
135
135
|
# never sent to S3. You can use a symetric key or an asymmetric
|
|
136
136
|
# key pair.
|
|
137
137
|
#
|
|
138
|
-
#
|
|
138
|
+
# ### Symmetric Key Encryption
|
|
139
139
|
#
|
|
140
140
|
# An AES key is used for symmetric encryption. The key can be 128, 192,
|
|
141
141
|
# and 256 bit sizes. Start by generating key or read a previously
|
|
142
142
|
# generated key.
|
|
143
143
|
#
|
|
144
|
-
#
|
|
145
|
-
#
|
|
144
|
+
# # generate a new random key
|
|
145
|
+
# my_key = OpenSSL::Cipher.new("AES-256-ECB").random_key
|
|
146
146
|
#
|
|
147
|
-
#
|
|
148
|
-
#
|
|
147
|
+
# # read an existing key from disk
|
|
148
|
+
# my_key = File.read("my_key.der")
|
|
149
149
|
#
|
|
150
150
|
# Now you can encrypt locally and upload the encrypted data to S3.
|
|
151
151
|
# To do this, you need to provide your key.
|
|
152
152
|
#
|
|
153
|
-
#
|
|
153
|
+
# obj = bucket.objects["my-text-object"]
|
|
154
154
|
#
|
|
155
|
-
#
|
|
156
|
-
#
|
|
155
|
+
# # encrypt then upload data
|
|
156
|
+
# obj.write("MY TEXT", :encryption_key => my_key)
|
|
157
157
|
#
|
|
158
|
-
#
|
|
159
|
-
#
|
|
160
|
-
#
|
|
158
|
+
# # try read the object without decrypting, oops
|
|
159
|
+
# obj.read
|
|
160
|
+
# #=> '.....'
|
|
161
161
|
#
|
|
162
162
|
# Lastly, you can download and decrypt by providing the same key.
|
|
163
163
|
#
|
|
164
|
-
#
|
|
165
|
-
#
|
|
164
|
+
# obj.read(:encryption_key => my_key)
|
|
165
|
+
# #=> "MY TEXT"
|
|
166
166
|
#
|
|
167
|
-
#
|
|
167
|
+
# ### Asymmetric Key Pair
|
|
168
168
|
#
|
|
169
169
|
# A RSA key pair is used for asymmetric encryption. The public key is used
|
|
170
170
|
# for encryption and the private key is used for decryption. Start
|
|
171
171
|
# by generating a key.
|
|
172
172
|
#
|
|
173
|
-
#
|
|
173
|
+
# my_key = OpenSSL::PKey::RSA.new(1024)
|
|
174
174
|
#
|
|
175
175
|
# Provide your key to #write and the data will be encrypted before it
|
|
176
176
|
# is uploaded. Pass the same key to #read to decrypt the data
|
|
177
177
|
# when you download it.
|
|
178
178
|
#
|
|
179
|
-
#
|
|
179
|
+
# obj = bucket.objects["my-text-object"]
|
|
180
180
|
#
|
|
181
|
-
#
|
|
182
|
-
#
|
|
181
|
+
# # encrypt and upload the data
|
|
182
|
+
# obj.write("MY TEXT", :encryption_key => my_key)
|
|
183
183
|
#
|
|
184
|
-
#
|
|
185
|
-
#
|
|
186
|
-
#
|
|
184
|
+
# # download and decrypt the data
|
|
185
|
+
# obj.read(:encryption_key => my_key)
|
|
186
|
+
# #=> "MY TEXT"
|
|
187
187
|
#
|
|
188
|
-
#
|
|
188
|
+
# ### Configuring storage locations
|
|
189
189
|
#
|
|
190
190
|
# By default, encryption materials are stored in the object metadata.
|
|
191
191
|
# If you prefer, you can store the encryption materials in a separate
|
|
192
192
|
# object in S3. This object will have the same key + '.instruction'.
|
|
193
193
|
#
|
|
194
|
-
#
|
|
195
|
-
#
|
|
194
|
+
# # new object, does not exist yet
|
|
195
|
+
# obj = bucket.objects["my-text-object"]
|
|
196
196
|
#
|
|
197
|
-
#
|
|
198
|
-
#
|
|
199
|
-
#
|
|
197
|
+
# # no instruction file present
|
|
198
|
+
# bucket.objects['my-text-object.instruction'].exists?
|
|
199
|
+
# #=> false
|
|
200
200
|
#
|
|
201
|
-
#
|
|
202
|
-
#
|
|
203
|
-
#
|
|
204
|
-
#
|
|
205
|
-
#
|
|
201
|
+
# # store the encryption materials in the instruction file
|
|
202
|
+
# # instead of obj#metadata
|
|
203
|
+
# obj.write("MY TEXT",
|
|
204
|
+
# :encryption_key => MY_KEY,
|
|
205
|
+
# :encryption_materials_location => :instruction_file)
|
|
206
206
|
#
|
|
207
|
-
#
|
|
208
|
-
#
|
|
207
|
+
# bucket.objects['my-text-object.instruction'].exists?
|
|
208
|
+
# #=> true
|
|
209
209
|
#
|
|
210
210
|
# If you store the encryption materials in an instruction file, you
|
|
211
211
|
# must tell #read this or it will fail to find your encryption materials.
|
|
212
212
|
#
|
|
213
|
-
#
|
|
214
|
-
#
|
|
215
|
-
#
|
|
216
|
-
#
|
|
213
|
+
# # reading an encrypted file whos materials are stored in an
|
|
214
|
+
# # instruction file, and not metadata
|
|
215
|
+
# obj.read(:encryption_key => MY_KEY,
|
|
216
|
+
# :encryption_materials_location => :instruction_file)
|
|
217
217
|
#
|
|
218
|
-
#
|
|
218
|
+
# ### Configuring default behaviors
|
|
219
219
|
#
|
|
220
220
|
# You can configure the default key such that it will automatically
|
|
221
221
|
# encrypt and decrypt for you. You can do this globally or for a
|
|
222
222
|
# single S3 interface
|
|
223
223
|
#
|
|
224
|
-
#
|
|
225
|
-
#
|
|
226
|
-
#
|
|
224
|
+
# # all objects uploaded/downloaded with this s3 object will be
|
|
225
|
+
# # encrypted/decrypted
|
|
226
|
+
# s3 = AWS::S3.new(:s3_encryption_key => "MY_KEY")
|
|
227
227
|
#
|
|
228
|
-
#
|
|
229
|
-
#
|
|
228
|
+
# # set the key to always encrypt/decrypt
|
|
229
|
+
# AWS.config(:s3_encryption_key => "MY_KEY")
|
|
230
230
|
#
|
|
231
231
|
# You can also configure the default storage location for the encryption
|
|
232
232
|
# materials.
|
|
233
233
|
#
|
|
234
|
-
#
|
|
234
|
+
# AWS.config(:s3_encryption_materials_location => :instruction_file)
|
|
235
235
|
#
|
|
236
236
|
class S3Object
|
|
237
237
|
|
|
@@ -266,7 +266,7 @@ module AWS
|
|
|
266
266
|
end
|
|
267
267
|
alias_method :eql?, :==
|
|
268
268
|
|
|
269
|
-
# @return [Boolean] Returns
|
|
269
|
+
# @return [Boolean] Returns `true` if the object exists in S3.
|
|
270
270
|
def exists?
|
|
271
271
|
head
|
|
272
272
|
rescue Errors::NoSuchKey => e
|
|
@@ -283,7 +283,7 @@ module AWS
|
|
|
283
283
|
# * content_type (as sent to S3 when uploading the object)
|
|
284
284
|
# * etag (typically the object's MD5)
|
|
285
285
|
# * server_side_encryption (the algorithm used to encrypt the
|
|
286
|
-
# object on the server side, e.g.
|
|
286
|
+
# object on the server side, e.g. `:aes256`)
|
|
287
287
|
#
|
|
288
288
|
# @param [Hash] options
|
|
289
289
|
# @option options [String] :version_id Which version of this object
|
|
@@ -337,7 +337,7 @@ module AWS
|
|
|
337
337
|
end
|
|
338
338
|
|
|
339
339
|
# @return [Symbol, nil] Returns the algorithm used to encrypt
|
|
340
|
-
# the object on the server side, or
|
|
340
|
+
# the object on the server side, or `nil` if SSE was not used
|
|
341
341
|
# when storing the object.
|
|
342
342
|
def server_side_encryption
|
|
343
343
|
head[:server_side_encryption]
|
|
@@ -382,7 +382,7 @@ module AWS
|
|
|
382
382
|
# of this object will be deleted. Only works for buckets that have
|
|
383
383
|
# had versioning enabled.
|
|
384
384
|
#
|
|
385
|
-
# @option [Boolean] :delete_instruction_file (false) Set this to
|
|
385
|
+
# @option [Boolean] :delete_instruction_file (false) Set this to `true`
|
|
386
386
|
# if you use client-side encryption and the encryption materials
|
|
387
387
|
# were stored in a separate object in S3 (key.instruction).
|
|
388
388
|
#
|
|
@@ -407,7 +407,7 @@ module AWS
|
|
|
407
407
|
end
|
|
408
408
|
|
|
409
409
|
# Restores a temporary copy of an archived object from the
|
|
410
|
-
# Glacier storage tier. After the specified
|
|
410
|
+
# Glacier storage tier. After the specified `days`, Amazon
|
|
411
411
|
# S3 deletes the temporary copy. Note that the object
|
|
412
412
|
# remains archived; Amazon S3 deletes only the restored copy.
|
|
413
413
|
#
|
|
@@ -415,7 +415,7 @@ module AWS
|
|
|
415
415
|
# {#restore_in_progress?} to check the status of the operation.
|
|
416
416
|
#
|
|
417
417
|
# @option [Integer] :days (1) the number of days to keep the object
|
|
418
|
-
# @return [Boolean]
|
|
418
|
+
# @return [Boolean] `true` if a restore can be initiated.
|
|
419
419
|
# @since 1.7.2
|
|
420
420
|
def restore options = {}
|
|
421
421
|
options[:days] ||= 1
|
|
@@ -439,6 +439,8 @@ module AWS
|
|
|
439
439
|
# Returns a collection representing all the object versions
|
|
440
440
|
# for this object.
|
|
441
441
|
#
|
|
442
|
+
# @example
|
|
443
|
+
#
|
|
442
444
|
# bucket.versioning_enabled? # => true
|
|
443
445
|
# version = bucket.objects["mykey"].versions.latest
|
|
444
446
|
#
|
|
@@ -449,32 +451,32 @@ module AWS
|
|
|
449
451
|
|
|
450
452
|
# Uploads data to the object in S3.
|
|
451
453
|
#
|
|
452
|
-
#
|
|
454
|
+
# obj = s3.buckets['bucket-name'].objects['key']
|
|
453
455
|
#
|
|
454
|
-
#
|
|
455
|
-
#
|
|
456
|
+
# # strings
|
|
457
|
+
# obj.write("HELLO")
|
|
456
458
|
#
|
|
457
|
-
#
|
|
458
|
-
#
|
|
459
|
+
# # files (by path)
|
|
460
|
+
# obj.write(Pathname.new('path/to/file.txt'))
|
|
459
461
|
#
|
|
460
|
-
#
|
|
461
|
-
#
|
|
462
|
+
# # file objects
|
|
463
|
+
# obj.write(File.open('path/to/file.txt', 'r'))
|
|
462
464
|
#
|
|
463
|
-
#
|
|
464
|
-
#
|
|
465
|
+
# # IO objects (must respond to #read and #eof?)
|
|
466
|
+
# obj.write(io)
|
|
465
467
|
#
|
|
466
|
-
#
|
|
468
|
+
# ### Multipart Uploads vs Single Uploads
|
|
467
469
|
#
|
|
468
470
|
# This method will intelligently choose between uploading the
|
|
469
471
|
# file in a signal request and using {#multipart_upload}.
|
|
470
472
|
# You can control this behavior by configuring the thresholds
|
|
471
473
|
# and you can disable the multipart feature as well.
|
|
472
474
|
#
|
|
473
|
-
#
|
|
474
|
-
#
|
|
475
|
+
# # always send the file in a single request
|
|
476
|
+
# obj.write(file, :single_request => true)
|
|
475
477
|
#
|
|
476
|
-
#
|
|
477
|
-
#
|
|
478
|
+
# # upload the file in parts if the total file size exceeds 100MB
|
|
479
|
+
# obj.write(file, :multipart_threshold => 100 * 1024 * 1024)
|
|
478
480
|
#
|
|
479
481
|
# @overload write(data, options = {})
|
|
480
482
|
#
|
|
@@ -484,25 +486,25 @@ module AWS
|
|
|
484
486
|
# * Pathname
|
|
485
487
|
# * File
|
|
486
488
|
# * IO
|
|
487
|
-
# * Any object that responds to
|
|
489
|
+
# * Any object that responds to `#read` and `#eof?`.
|
|
488
490
|
#
|
|
489
491
|
# @param options [Hash] Additional upload options.
|
|
490
492
|
#
|
|
491
493
|
# @option options [Integer] :content_length If provided, this
|
|
492
494
|
# option must match the total number of bytes written to S3.
|
|
493
495
|
# This options is *required* when it is not possible to
|
|
494
|
-
# automatically determine the size of
|
|
496
|
+
# automatically determine the size of `data`.
|
|
495
497
|
#
|
|
496
498
|
# @option options [Integer] :estimated_content_length When uploading
|
|
497
499
|
# data of unknown content length, you may specify this option to
|
|
498
500
|
# hint what mode of upload should take place. When
|
|
499
|
-
#
|
|
501
|
+
# `:estimated_content_length` exceeds the `:multipart_threshold`,
|
|
500
502
|
# then the data will be uploaded in parts, otherwise it will
|
|
501
503
|
# be read into memory and uploaded via {Client#put_object}.
|
|
502
504
|
#
|
|
503
|
-
# @option options [Boolean] :single_request (false) When
|
|
505
|
+
# @option options [Boolean] :single_request (false) When `true`,
|
|
504
506
|
# this method will always upload the data in a single request
|
|
505
|
-
# (via {Client#put_object}). When
|
|
507
|
+
# (via {Client#put_object}). When `false`, this method will
|
|
506
508
|
# choose between {Client#put_object} and {#multipart_upload}.
|
|
507
509
|
#
|
|
508
510
|
# @option options [Integer] :multipart_threshold (16777216) Specifies
|
|
@@ -519,18 +521,18 @@ module AWS
|
|
|
519
521
|
#
|
|
520
522
|
# @option options [Hash] :metadata A hash of metadata to be
|
|
521
523
|
# included with the object. These will be sent to S3 as
|
|
522
|
-
# headers prefixed with
|
|
524
|
+
# headers prefixed with `x-amz-meta`. Each name, value pair
|
|
523
525
|
# must conform to US-ASCII.
|
|
524
526
|
#
|
|
525
527
|
# @option options [Symbol,String] :acl (:private) A canned access
|
|
526
528
|
# control policy. Valid values are:
|
|
527
529
|
#
|
|
528
|
-
# *
|
|
529
|
-
# *
|
|
530
|
-
# *
|
|
531
|
-
# *
|
|
532
|
-
# *
|
|
533
|
-
# *
|
|
530
|
+
# * `:private`
|
|
531
|
+
# * `:public_read`
|
|
532
|
+
# * `:public_read_write`
|
|
533
|
+
# * `:authenticated_read`
|
|
534
|
+
# * `:bucket_owner_read`
|
|
535
|
+
# * `:bucket_owner_full_control`
|
|
534
536
|
#
|
|
535
537
|
# @option options [String] :grant_read
|
|
536
538
|
#
|
|
@@ -542,7 +544,7 @@ module AWS
|
|
|
542
544
|
#
|
|
543
545
|
# @option options [String] :grant_full_control
|
|
544
546
|
#
|
|
545
|
-
# @option options [Boolean] :reduced_redundancy (false) When
|
|
547
|
+
# @option options [Boolean] :reduced_redundancy (false) When `true`,
|
|
546
548
|
# this object will be stored with Reduced Redundancy Storage.
|
|
547
549
|
#
|
|
548
550
|
# @option options :cache_control [String] Can be used to specify
|
|
@@ -556,7 +558,7 @@ module AWS
|
|
|
556
558
|
# @option options :content_encoding [String] Specifies what
|
|
557
559
|
# content encodings have been applied to the object and thus
|
|
558
560
|
# what decoding mechanisms must be applied to obtain the
|
|
559
|
-
# media-type referenced by the
|
|
561
|
+
# media-type referenced by the `Content-Type` header field.
|
|
560
562
|
# See
|
|
561
563
|
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11
|
|
562
564
|
#
|
|
@@ -568,10 +570,10 @@ module AWS
|
|
|
568
570
|
#
|
|
569
571
|
# @option options [Symbol] :server_side_encryption (nil) If this
|
|
570
572
|
# option is set, the object will be stored using server side
|
|
571
|
-
# encryption. The only valid value is
|
|
573
|
+
# encryption. The only valid value is `:aes256`, which
|
|
572
574
|
# specifies that the object should be stored using the AES
|
|
573
575
|
# encryption algorithm with 256 bit keys. By default, this
|
|
574
|
-
# option uses the value of the
|
|
576
|
+
# option uses the value of the `:s3_server_side_encryption`
|
|
575
577
|
# option in the current configuration; for more information,
|
|
576
578
|
# see {AWS.config}.
|
|
577
579
|
#
|
|
@@ -581,7 +583,7 @@ module AWS
|
|
|
581
583
|
# or a symmetric key string (16, 24 or 32 bytes in length).
|
|
582
584
|
#
|
|
583
585
|
# @option options [Symbol] :encryption_materials_location (:metadata)
|
|
584
|
-
# Set this to
|
|
586
|
+
# Set this to `:instruction_file` if you prefer to store the
|
|
585
587
|
# client-side encryption materials in a separate object in S3
|
|
586
588
|
# instead of in the object metadata.
|
|
587
589
|
#
|
|
@@ -590,7 +592,7 @@ module AWS
|
|
|
590
592
|
#
|
|
591
593
|
# @return [S3Object, ObjectVersion] If the bucket has versioning
|
|
592
594
|
# enabled, this methods returns an {ObjectVersion}, otherwise
|
|
593
|
-
# this method returns
|
|
595
|
+
# this method returns `self`.
|
|
594
596
|
#
|
|
595
597
|
def write *args, &block
|
|
596
598
|
|
|
@@ -615,24 +617,28 @@ module AWS
|
|
|
615
617
|
# to use.
|
|
616
618
|
#
|
|
617
619
|
# @example Uploading an object in two parts
|
|
620
|
+
#
|
|
618
621
|
# bucket.objects.myobject.multipart_upload do |upload|
|
|
619
622
|
# upload.add_part("a" * 5242880)
|
|
620
623
|
# upload.add_part("b" * 2097152)
|
|
621
624
|
# end
|
|
622
625
|
#
|
|
623
626
|
# @example Uploading parts out of order
|
|
627
|
+
#
|
|
624
628
|
# bucket.objects.myobject.multipart_upload do |upload|
|
|
625
629
|
# upload.add_part("b" * 2097152, :part_number => 2)
|
|
626
630
|
# upload.add_part("a" * 5242880, :part_number => 1)
|
|
627
631
|
# end
|
|
628
632
|
#
|
|
629
633
|
# @example Aborting an upload after parts have been added
|
|
634
|
+
#
|
|
630
635
|
# bucket.objects.myobject.multipart_upload do |upload|
|
|
631
636
|
# upload.add_part("b" * 2097152, :part_number => 2)
|
|
632
637
|
# upload.abort
|
|
633
638
|
# end
|
|
634
639
|
#
|
|
635
640
|
# @example Starting an upload and completing it later by ID
|
|
641
|
+
#
|
|
636
642
|
# upload = bucket.objects.myobject.multipart_upload
|
|
637
643
|
# upload.add_part("a" * 5242880)
|
|
638
644
|
# upload.add_part("b" * 2097152)
|
|
@@ -643,7 +649,7 @@ module AWS
|
|
|
643
649
|
# upload.complete(:remote_parts)
|
|
644
650
|
#
|
|
645
651
|
# @yieldparam [MultipartUpload] upload A handle to the upload.
|
|
646
|
-
# {MultipartUpload#close} is called in an
|
|
652
|
+
# {MultipartUpload#close} is called in an `ensure` clause so
|
|
647
653
|
# that the upload will always be either completed or
|
|
648
654
|
# aborted.
|
|
649
655
|
#
|
|
@@ -651,18 +657,18 @@ module AWS
|
|
|
651
657
|
#
|
|
652
658
|
# @option options [Hash] :metadata A hash of metadata to be
|
|
653
659
|
# included with the object. These will be sent to S3 as
|
|
654
|
-
# headers prefixed with
|
|
660
|
+
# headers prefixed with `x-amz-meta`. Each name, value pair
|
|
655
661
|
# must conform to US-ASCII.
|
|
656
662
|
#
|
|
657
663
|
# @option options [Symbol] :acl (private) A canned access
|
|
658
664
|
# control policy. Valid values are:
|
|
659
665
|
#
|
|
660
|
-
# *
|
|
661
|
-
# *
|
|
662
|
-
# *
|
|
663
|
-
# *
|
|
664
|
-
# *
|
|
665
|
-
# *
|
|
666
|
+
# * `:private`
|
|
667
|
+
# * `:public_read`
|
|
668
|
+
# * `:public_read_write`
|
|
669
|
+
# * `:authenticated_read`
|
|
670
|
+
# * `:bucket_owner_read`
|
|
671
|
+
# * `:bucket_owner_full_control`
|
|
666
672
|
#
|
|
667
673
|
# @option options [Boolean] :reduced_redundancy (false) If true,
|
|
668
674
|
# Reduced Redundancy Storage will be enabled for the uploaded
|
|
@@ -679,7 +685,7 @@ module AWS
|
|
|
679
685
|
# @option options :content_encoding [String] Specifies what
|
|
680
686
|
# content encodings have been applied to the object and thus
|
|
681
687
|
# what decoding mechanisms must be applied to obtain the
|
|
682
|
-
# media-type referenced by the
|
|
688
|
+
# media-type referenced by the `Content-Type` header field.
|
|
683
689
|
# See
|
|
684
690
|
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11
|
|
685
691
|
#
|
|
@@ -688,10 +694,10 @@ module AWS
|
|
|
688
694
|
#
|
|
689
695
|
# @option options [Symbol] :server_side_encryption (nil) If this
|
|
690
696
|
# option is set, the object will be stored using server side
|
|
691
|
-
# encryption. The only valid value is
|
|
697
|
+
# encryption. The only valid value is `:aes256`, which
|
|
692
698
|
# specifies that the object should be stored using the AES
|
|
693
699
|
# encryption algorithm with 256 bit keys. By default, this
|
|
694
|
-
# option uses the value of the
|
|
700
|
+
# option uses the value of the `:s3_server_side_encryption`
|
|
695
701
|
# option in the current configuration; for more information,
|
|
696
702
|
# see {AWS.config}.
|
|
697
703
|
#
|
|
@@ -736,23 +742,23 @@ module AWS
|
|
|
736
742
|
# deleting the old object. This function returns the
|
|
737
743
|
# new object once this is done.
|
|
738
744
|
#
|
|
739
|
-
#
|
|
740
|
-
#
|
|
745
|
+
# bucket = s3.buckets['old-bucket']
|
|
746
|
+
# old_obj = bucket.objects['old-key']
|
|
741
747
|
#
|
|
742
|
-
#
|
|
743
|
-
#
|
|
748
|
+
# # renaming an object returns a new object
|
|
749
|
+
# new_obj = old_obj.move_to('new-key')
|
|
744
750
|
#
|
|
745
|
-
#
|
|
746
|
-
#
|
|
751
|
+
# old_obj.key #=> 'old-key'
|
|
752
|
+
# old_obj.exists? #=> false
|
|
747
753
|
#
|
|
748
|
-
#
|
|
749
|
-
#
|
|
754
|
+
# new_obj.key #=> 'new-key'
|
|
755
|
+
# new_obj.exists? #=> true
|
|
750
756
|
#
|
|
751
757
|
# If you need to move an object to a different bucket, pass
|
|
752
|
-
#
|
|
758
|
+
# `:bucket` or `:bucket_name`.
|
|
753
759
|
#
|
|
754
|
-
#
|
|
755
|
-
#
|
|
760
|
+
# obj = s3.buckets['old-bucket'].objects['old-key']
|
|
761
|
+
# obj.move_to('new-key', :bucket_name => 'new_bucket')
|
|
756
762
|
#
|
|
757
763
|
# If the copy succeeds, but the then the delete fails, an error
|
|
758
764
|
# will be raised.
|
|
@@ -812,19 +818,19 @@ module AWS
|
|
|
812
818
|
# @option options [Symbol] :acl (private) A canned access
|
|
813
819
|
# control policy. Valid values are:
|
|
814
820
|
#
|
|
815
|
-
# *
|
|
816
|
-
# *
|
|
817
|
-
# *
|
|
818
|
-
# *
|
|
819
|
-
# *
|
|
820
|
-
# *
|
|
821
|
+
# * `:private`
|
|
822
|
+
# * `:public_read`
|
|
823
|
+
# * `:public_read_write`
|
|
824
|
+
# * `:authenticated_read`
|
|
825
|
+
# * `:bucket_owner_read`
|
|
826
|
+
# * `:bucket_owner_full_control`
|
|
821
827
|
#
|
|
822
828
|
# @option options [Symbol] :server_side_encryption (nil) If this
|
|
823
829
|
# option is set, the object will be stored using server side
|
|
824
|
-
# encryption. The only valid value is
|
|
830
|
+
# encryption. The only valid value is `:aes256`, which
|
|
825
831
|
# specifies that the object should be stored using the AES
|
|
826
832
|
# encryption algorithm with 256 bit keys. By default, this
|
|
827
|
-
# option uses the value of the
|
|
833
|
+
# option uses the value of the `:s3_server_side_encryption`
|
|
828
834
|
# option in the current configuration; for more information,
|
|
829
835
|
# see {AWS.config}.
|
|
830
836
|
#
|
|
@@ -924,23 +930,23 @@ module AWS
|
|
|
924
930
|
# @option options [Symbol] :acl (private) A canned access
|
|
925
931
|
# control policy. Valid values are:
|
|
926
932
|
#
|
|
927
|
-
# *
|
|
928
|
-
# *
|
|
929
|
-
# *
|
|
930
|
-
# *
|
|
931
|
-
# *
|
|
932
|
-
# *
|
|
933
|
+
# * `:private`
|
|
934
|
+
# * `:public_read`
|
|
935
|
+
# * `:public_read_write`
|
|
936
|
+
# * `:authenticated_read`
|
|
937
|
+
# * `:bucket_owner_read`
|
|
938
|
+
# * `:bucket_owner_full_control`
|
|
933
939
|
#
|
|
934
940
|
# @option options [Symbol] :server_side_encryption (nil) If this
|
|
935
941
|
# option is set, the object will be stored using server side
|
|
936
|
-
# encryption. The only valid value is
|
|
942
|
+
# encryption. The only valid value is `:aes256`, which
|
|
937
943
|
# specifies that the object should be stored using the AES
|
|
938
944
|
# encryption algorithm with 256 bit keys. By default, this
|
|
939
|
-
# option uses the value of the
|
|
945
|
+
# option uses the value of the `:s3_server_side_encryption`
|
|
940
946
|
# option in the current configuration; for more information,
|
|
941
947
|
# see {AWS.config}.
|
|
942
948
|
#
|
|
943
|
-
# @option options [Boolean] :client_side_encrypted (false) When
|
|
949
|
+
# @option options [Boolean] :client_side_encrypted (false) When `true`,
|
|
944
950
|
# the client-side encryption materials will be copied. Without this
|
|
945
951
|
# option, the key and iv are not guaranteed to be transferred to
|
|
946
952
|
# the new object.
|
|
@@ -977,27 +983,27 @@ module AWS
|
|
|
977
983
|
# method, the data will be yielded to the block in chunks as it
|
|
978
984
|
# is read off the HTTP response.
|
|
979
985
|
#
|
|
980
|
-
#
|
|
986
|
+
# ### Read an object from S3 in chunks
|
|
981
987
|
#
|
|
982
988
|
# When downloading large objects it is recommended to pass a block
|
|
983
989
|
# to #read. Data will be yielded to the block as it is read off
|
|
984
990
|
# the HTTP response.
|
|
985
991
|
#
|
|
986
|
-
#
|
|
987
|
-
#
|
|
988
|
-
#
|
|
989
|
-
#
|
|
992
|
+
# # read an object from S3 to a file
|
|
993
|
+
# File.open('output.txt', 'w') do |file|
|
|
994
|
+
# bucket.objects['key'].read do |chunk|
|
|
995
|
+
# file.write(chunk)
|
|
996
|
+
# end
|
|
990
997
|
# end
|
|
991
|
-
# end
|
|
992
998
|
#
|
|
993
|
-
#
|
|
999
|
+
# ### Reading an object without a block
|
|
994
1000
|
#
|
|
995
1001
|
# When you omit the block argument to #read, then the entire
|
|
996
1002
|
# HTTP response and read and the object data is loaded into
|
|
997
1003
|
# memory.
|
|
998
1004
|
#
|
|
999
|
-
#
|
|
1000
|
-
#
|
|
1005
|
+
# bucket.objects['key'].read
|
|
1006
|
+
# #=> 'object-contents-here'
|
|
1001
1007
|
#
|
|
1002
1008
|
# @param [Hash] options
|
|
1003
1009
|
#
|
|
@@ -1006,19 +1012,19 @@ module AWS
|
|
|
1006
1012
|
#
|
|
1007
1013
|
# @option options [Time] :if_unmodified_since If specified, the
|
|
1008
1014
|
# method will raise
|
|
1009
|
-
#
|
|
1015
|
+
# `AWS::S3::Errors::PreconditionFailed` unless the
|
|
1010
1016
|
# object has not been modified since the given time.
|
|
1011
1017
|
#
|
|
1012
1018
|
# @option options [Time] :if_modified_since If specified, the
|
|
1013
|
-
# method will raise
|
|
1019
|
+
# method will raise `AWS::S3::Errors::NotModified` if
|
|
1014
1020
|
# the object has not been modified since the given time.
|
|
1015
1021
|
#
|
|
1016
1022
|
# @option options [String] :if_match If specified, the method
|
|
1017
|
-
# will raise
|
|
1023
|
+
# will raise `AWS::S3::Errors::PreconditionFailed`
|
|
1018
1024
|
# unless the object ETag matches the provided value.
|
|
1019
1025
|
#
|
|
1020
1026
|
# @option options [String] :if_none_match If specified, the
|
|
1021
|
-
# method will raise
|
|
1027
|
+
# method will raise `AWS::S3::Errors::NotModified` if
|
|
1022
1028
|
# the object ETag matches the provided value.
|
|
1023
1029
|
#
|
|
1024
1030
|
# @option options [Range] :range A byte range to read data from
|
|
@@ -1026,9 +1032,9 @@ module AWS
|
|
|
1026
1032
|
# @option options [OpenSSL::PKey::RSA, String] :encryption_key
|
|
1027
1033
|
# (nil) If this option is set, the object will be decrypted using
|
|
1028
1034
|
# envelope encryption. The valid values are OpenSSL asymmetric keys
|
|
1029
|
-
#
|
|
1030
|
-
# of an AES-128/192/256-ECB cipher as a
|
|
1031
|
-
# This value defaults to the value in
|
|
1035
|
+
# `OpenSSL::Pkey::RSA` or strings representing symmetric keys
|
|
1036
|
+
# of an AES-128/192/256-ECB cipher as a `String`.
|
|
1037
|
+
# This value defaults to the value in `s3_encryption_key`;
|
|
1032
1038
|
# for more information, see {AWS.config}.
|
|
1033
1039
|
#
|
|
1034
1040
|
# Symmetric Keys:
|
|
@@ -1040,10 +1046,10 @@ module AWS
|
|
|
1040
1046
|
# key = OpenSSL::PKey::RSA.new(KEY_SIZE)
|
|
1041
1047
|
#
|
|
1042
1048
|
# @option options [Symbol] :encryption_materials_location (:metadata)
|
|
1043
|
-
# Set this to
|
|
1049
|
+
# Set this to `:instruction_file` if the encryption materials
|
|
1044
1050
|
# are not stored in the object metadata
|
|
1045
1051
|
#
|
|
1046
|
-
# @note
|
|
1052
|
+
# @note `:range` option cannot be used with client-side encryption
|
|
1047
1053
|
#
|
|
1048
1054
|
# @note All decryption reads incur at least an extra HEAD operation.
|
|
1049
1055
|
#
|
|
@@ -1074,16 +1080,16 @@ module AWS
|
|
|
1074
1080
|
end
|
|
1075
1081
|
|
|
1076
1082
|
# Returns the object's access control list. This will be an
|
|
1077
|
-
# instance of AccessControlList, plus an additional
|
|
1083
|
+
# instance of AccessControlList, plus an additional `change`
|
|
1078
1084
|
# method:
|
|
1079
1085
|
#
|
|
1080
|
-
#
|
|
1081
|
-
#
|
|
1082
|
-
#
|
|
1083
|
-
#
|
|
1084
|
-
#
|
|
1085
|
-
#
|
|
1086
|
-
#
|
|
1086
|
+
# object.acl.change do |acl|
|
|
1087
|
+
# # remove any grants to someone other than the bucket owner
|
|
1088
|
+
# owner_id = object.bucket.owner.id
|
|
1089
|
+
# acl.grants.reject! do |g|
|
|
1090
|
+
# g.grantee.canonical_user_id != owner_id
|
|
1091
|
+
# end
|
|
1092
|
+
# end
|
|
1087
1093
|
#
|
|
1088
1094
|
# Note that changing the ACL is not an atomic operation; it
|
|
1089
1095
|
# fetches the current ACL, yields it to the block, and then
|
|
@@ -1130,26 +1136,30 @@ module AWS
|
|
|
1130
1136
|
# the permissions of the object.
|
|
1131
1137
|
#
|
|
1132
1138
|
# @example Generate a url to read an object
|
|
1139
|
+
#
|
|
1133
1140
|
# bucket.objects.myobject.url_for(:read)
|
|
1134
1141
|
#
|
|
1135
1142
|
# @example Generate a url to delete an object
|
|
1143
|
+
#
|
|
1136
1144
|
# bucket.objects.myobject.url_for(:delete)
|
|
1137
1145
|
#
|
|
1138
1146
|
# @example Override response headers for reading an object
|
|
1147
|
+
#
|
|
1139
1148
|
# object = bucket.objects.myobject
|
|
1140
1149
|
# url = object.url_for(:read,
|
|
1141
1150
|
# :response_content_type => "application/json")
|
|
1142
1151
|
#
|
|
1143
1152
|
# @example Generate a url that expires in 10 minutes
|
|
1153
|
+
#
|
|
1144
1154
|
# bucket.objects.myobject.url_for(:read, :expires => 10*60)
|
|
1145
1155
|
#
|
|
1146
1156
|
# @param [Symbol, String] method The HTTP verb or object
|
|
1147
1157
|
# method for which the returned URL will be valid. Valid
|
|
1148
1158
|
# values:
|
|
1149
1159
|
#
|
|
1150
|
-
# *
|
|
1151
|
-
# *
|
|
1152
|
-
# *
|
|
1160
|
+
# * `:get` or `:read`
|
|
1161
|
+
# * `:put` or `:write`
|
|
1162
|
+
# * `:delete`
|
|
1153
1163
|
#
|
|
1154
1164
|
# @param [Hash] options Additional options for generating the URL.
|
|
1155
1165
|
#
|
|
@@ -1164,7 +1174,7 @@ module AWS
|
|
|
1164
1174
|
# secure (HTTPS) URL or a plain HTTP url.
|
|
1165
1175
|
#
|
|
1166
1176
|
# @option options [String] :endpoint Sets the hostname of the
|
|
1167
|
-
# endpoint
|
|
1177
|
+
# endpoint.
|
|
1168
1178
|
#
|
|
1169
1179
|
# @option options [Integer] :port Sets the port of the
|
|
1170
1180
|
# endpoint (overrides config.s3_port).
|
|
@@ -1254,7 +1264,7 @@ module AWS
|
|
|
1254
1264
|
# lower cost. Otherwise, the object will be copied and stored
|
|
1255
1265
|
# with the standard storage class.
|
|
1256
1266
|
#
|
|
1257
|
-
# @return [true,false] The
|
|
1267
|
+
# @return [true,false] The `value` parameter.
|
|
1258
1268
|
def reduced_redundancy= value
|
|
1259
1269
|
copy_from(key, :reduced_redundancy => value)
|
|
1260
1270
|
value
|
|
@@ -1287,7 +1297,7 @@ module AWS
|
|
|
1287
1297
|
end
|
|
1288
1298
|
end
|
|
1289
1299
|
|
|
1290
|
-
# @return [Boolean] Returns
|
|
1300
|
+
# @return [Boolean] Returns `true` if the :data option is large or
|
|
1291
1301
|
# guessed to be larger than a configured threshold.
|
|
1292
1302
|
def use_multipart? options
|
|
1293
1303
|
estimated_content_length(options) > multipart_threshold(options) and
|
|
@@ -1379,7 +1389,7 @@ module AWS
|
|
|
1379
1389
|
|
|
1380
1390
|
def request_for_signing(options)
|
|
1381
1391
|
|
|
1382
|
-
port = [443, 80].include?(config.s3_port) ?
|
|
1392
|
+
port = [443, 80].include?(config.s3_port) ?
|
|
1383
1393
|
(options[:secure] ? 443 : 80) :
|
|
1384
1394
|
config.s3_port
|
|
1385
1395
|
|
|
@@ -1674,13 +1684,13 @@ module AWS
|
|
|
1674
1684
|
end
|
|
1675
1685
|
end
|
|
1676
1686
|
|
|
1677
|
-
# @return [String] Encodes a
|
|
1687
|
+
# @return [String] Encodes a `String` in base 64 regardless of version of
|
|
1678
1688
|
# Ruby for http headers (removes newlines).
|
|
1679
1689
|
def encode64 input
|
|
1680
1690
|
Base64.encode64(input).split("\n") * ""
|
|
1681
1691
|
end
|
|
1682
1692
|
|
|
1683
|
-
# @return [String] Decodes a
|
|
1693
|
+
# @return [String] Decodes a `String` in base 64.
|
|
1684
1694
|
def decode64 input
|
|
1685
1695
|
Base64.decode64(input)
|
|
1686
1696
|
end
|