aws-sdk 1.32.0 → 1.67.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aws-sdk.rb +1 -15
- metadata +16 -589
- data/.yardopts +0 -7
- data/LICENSE.txt +0 -12
- data/README.md +0 -291
- data/bin/aws-rb +0 -169
- data/ca-bundle.crt +0 -3554
- data/endpoints.json +0 -1506
- data/lib/aws.rb +0 -14
- data/lib/aws/api_config/AutoScaling-2011-01-01.yml +0 -869
- data/lib/aws/api_config/CloudFormation-2010-05-15.yml +0 -358
- data/lib/aws/api_config/CloudFront-2013-05-12.yml +0 -2448
- data/lib/aws/api_config/CloudFront-2013-08-26.yml +0 -2599
- data/lib/aws/api_config/CloudFront-2013-09-27.yml +0 -2765
- data/lib/aws/api_config/CloudFront-2013-11-11.yml +0 -2886
- data/lib/aws/api_config/CloudSearch-2011-02-01.yml +0 -681
- data/lib/aws/api_config/CloudTrail-2013-11-01.yml +0 -159
- data/lib/aws/api_config/CloudWatch-2010-08-01.yml +0 -433
- data/lib/aws/api_config/DataPipeline-2012-10-29.yml +0 -422
- data/lib/aws/api_config/DirectConnect-2012-10-25.yml +0 -735
- data/lib/aws/api_config/DynamoDB-2011-12-05.yml +0 -1168
- data/lib/aws/api_config/DynamoDB-2012-08-10.yml +0 -2005
- data/lib/aws/api_config/EC2-2013-08-15.yml +0 -4708
- data/lib/aws/api_config/EC2-2013-10-01.yml +0 -4726
- data/lib/aws/api_config/EC2-2013-10-15.yml +0 -4726
- data/lib/aws/api_config/ELB-2012-06-01.yml +0 -632
- data/lib/aws/api_config/EMR-2009-03-31.yml +0 -953
- data/lib/aws/api_config/ElastiCache-2013-06-15.yml +0 -1188
- data/lib/aws/api_config/ElasticBeanstalk-2010-12-01.yml +0 -847
- data/lib/aws/api_config/ElasticTranscoder-2012-09-25.yml +0 -2285
- data/lib/aws/api_config/Glacier-2012-06-01.yml +0 -649
- data/lib/aws/api_config/IAM-2010-05-08.yml +0 -1297
- data/lib/aws/api_config/ImportExport-2010-06-01.yml +0 -109
- data/lib/aws/api_config/Kinesis-2013-12-02.yml +0 -201
- data/lib/aws/api_config/OpsWorks-2013-02-18.yml +0 -1825
- data/lib/aws/api_config/RDS-2013-05-15.yml +0 -2464
- data/lib/aws/api_config/RDS-2013-09-09.yml +0 -2641
- data/lib/aws/api_config/Redshift-2012-12-01.yml +0 -2137
- data/lib/aws/api_config/Route53-2012-12-12.yml +0 -547
- data/lib/aws/api_config/SNS-2010-03-31.yml +0 -433
- data/lib/aws/api_config/SQS-2012-11-05.yml +0 -319
- data/lib/aws/api_config/STS-2011-06-15.yml +0 -147
- data/lib/aws/api_config/SimpleDB-2009-04-15.yml +0 -306
- data/lib/aws/api_config/SimpleEmailService-2010-12-01.yml +0 -346
- data/lib/aws/api_config/SimpleWorkflow-2012-01-25.yml +0 -2388
- data/lib/aws/api_config/StorageGateway-2012-06-30.yml +0 -748
- data/lib/aws/api_config/StorageGateway-2013-06-30.yml +0 -1025
- data/lib/aws/api_config/Support-2013-04-15.yml +0 -426
- data/lib/aws/auto_scaling.rb +0 -163
- data/lib/aws/auto_scaling/activity.rb +0 -102
- data/lib/aws/auto_scaling/activity_collection.rb +0 -81
- data/lib/aws/auto_scaling/client.rb +0 -48
- data/lib/aws/auto_scaling/config.rb +0 -18
- data/lib/aws/auto_scaling/errors.rb +0 -22
- data/lib/aws/auto_scaling/group.rb +0 -421
- data/lib/aws/auto_scaling/group_collection.rb +0 -96
- data/lib/aws/auto_scaling/group_options.rb +0 -155
- data/lib/aws/auto_scaling/instance.rb +0 -192
- data/lib/aws/auto_scaling/instance_collection.rb +0 -63
- data/lib/aws/auto_scaling/launch_configuration.rb +0 -162
- data/lib/aws/auto_scaling/launch_configuration_collection.rb +0 -160
- data/lib/aws/auto_scaling/notification_configuration.rb +0 -89
- data/lib/aws/auto_scaling/notification_configuration_collection.rb +0 -183
- data/lib/aws/auto_scaling/scaling_policy.rb +0 -142
- data/lib/aws/auto_scaling/scaling_policy_collection.rb +0 -72
- data/lib/aws/auto_scaling/scaling_policy_options.rb +0 -65
- data/lib/aws/auto_scaling/scheduled_action.rb +0 -141
- data/lib/aws/auto_scaling/scheduled_action_collection.rb +0 -202
- data/lib/aws/auto_scaling/tag.rb +0 -59
- data/lib/aws/auto_scaling/tag_collection.rb +0 -114
- data/lib/aws/cloud_formation.rb +0 -272
- data/lib/aws/cloud_formation/client.rb +0 -48
- data/lib/aws/cloud_formation/config.rb +0 -18
- data/lib/aws/cloud_formation/errors.rb +0 -22
- data/lib/aws/cloud_formation/stack.rb +0 -266
- data/lib/aws/cloud_formation/stack_collection.rb +0 -232
- data/lib/aws/cloud_formation/stack_event.rb +0 -73
- data/lib/aws/cloud_formation/stack_event_collection.rb +0 -47
- data/lib/aws/cloud_formation/stack_options.rb +0 -72
- data/lib/aws/cloud_formation/stack_output.rb +0 -53
- data/lib/aws/cloud_formation/stack_resource.rb +0 -117
- data/lib/aws/cloud_formation/stack_resource_collection.rb +0 -83
- data/lib/aws/cloud_formation/stack_resource_summary_collection.rb +0 -64
- data/lib/aws/cloud_formation/stack_summary_collection.rb +0 -123
- data/lib/aws/cloud_front.rb +0 -72
- data/lib/aws/cloud_front/client.rb +0 -45
- data/lib/aws/cloud_front/config.rb +0 -18
- data/lib/aws/cloud_front/errors.rb +0 -22
- data/lib/aws/cloud_search.rb +0 -73
- data/lib/aws/cloud_search/client.rb +0 -36
- data/lib/aws/cloud_search/config.rb +0 -18
- data/lib/aws/cloud_search/errors.rb +0 -22
- data/lib/aws/cloud_trail.rb +0 -72
- data/lib/aws/cloud_trail/client.rb +0 -35
- data/lib/aws/cloud_trail/config.rb +0 -18
- data/lib/aws/cloud_trail/errors.rb +0 -22
- data/lib/aws/cloud_watch.rb +0 -118
- data/lib/aws/cloud_watch/alarm.rb +0 -290
- data/lib/aws/cloud_watch/alarm_collection.rb +0 -153
- data/lib/aws/cloud_watch/alarm_history_item.rb +0 -50
- data/lib/aws/cloud_watch/alarm_history_item_collection.rb +0 -84
- data/lib/aws/cloud_watch/client.rb +0 -40
- data/lib/aws/cloud_watch/config.rb +0 -18
- data/lib/aws/cloud_watch/errors.rb +0 -22
- data/lib/aws/cloud_watch/metric.rb +0 -135
- data/lib/aws/cloud_watch/metric_alarm_collection.rb +0 -160
- data/lib/aws/cloud_watch/metric_collection.rb +0 -129
- data/lib/aws/cloud_watch/metric_statistics.rb +0 -69
- data/lib/aws/core.rb +0 -701
- data/lib/aws/core/async_handle.rb +0 -90
- data/lib/aws/core/cacheable.rb +0 -77
- data/lib/aws/core/client.rb +0 -778
- data/lib/aws/core/collection.rb +0 -263
- data/lib/aws/core/collection/simple.rb +0 -82
- data/lib/aws/core/collection/with_limit_and_next_token.rb +0 -71
- data/lib/aws/core/collection/with_next_token.rb +0 -97
- data/lib/aws/core/configuration.rb +0 -541
- data/lib/aws/core/credential_providers.rb +0 -506
- data/lib/aws/core/data.rb +0 -247
- data/lib/aws/core/deprecations.rb +0 -84
- data/lib/aws/core/endpoints.rb +0 -37
- data/lib/aws/core/http/connection_pool.rb +0 -349
- data/lib/aws/core/http/curb_handler.rb +0 -148
- data/lib/aws/core/http/handler.rb +0 -89
- data/lib/aws/core/http/net_http_handler.rb +0 -147
- data/lib/aws/core/http/patch.rb +0 -102
- data/lib/aws/core/http/request.rb +0 -249
- data/lib/aws/core/http/response.rb +0 -81
- data/lib/aws/core/indifferent_hash.rb +0 -88
- data/lib/aws/core/inflection.rb +0 -56
- data/lib/aws/core/json_client.rb +0 -47
- data/lib/aws/core/json_parser.rb +0 -76
- data/lib/aws/core/json_request_builder.rb +0 -35
- data/lib/aws/core/json_response_parser.rb +0 -79
- data/lib/aws/core/lazy_error_classes.rb +0 -90
- data/lib/aws/core/log_formatter.rb +0 -428
- data/lib/aws/core/managed_file.rb +0 -32
- data/lib/aws/core/meta_utils.rb +0 -45
- data/lib/aws/core/model.rb +0 -57
- data/lib/aws/core/naming.rb +0 -30
- data/lib/aws/core/option_grammar.rb +0 -738
- data/lib/aws/core/options/json_serializer.rb +0 -82
- data/lib/aws/core/options/validator.rb +0 -155
- data/lib/aws/core/options/xml_serializer.rb +0 -118
- data/lib/aws/core/page_result.rb +0 -75
- data/lib/aws/core/policy.rb +0 -942
- data/lib/aws/core/query_client.rb +0 -41
- data/lib/aws/core/query_error_parser.rb +0 -24
- data/lib/aws/core/query_request_builder.rb +0 -47
- data/lib/aws/core/query_response_parser.rb +0 -35
- data/lib/aws/core/region.rb +0 -85
- data/lib/aws/core/region_collection.rb +0 -80
- data/lib/aws/core/resource.rb +0 -413
- data/lib/aws/core/resource_cache.rb +0 -40
- data/lib/aws/core/response.rb +0 -211
- data/lib/aws/core/response_cache.rb +0 -50
- data/lib/aws/core/rest_error_parser.rb +0 -24
- data/lib/aws/core/rest_json_client.rb +0 -40
- data/lib/aws/core/rest_request_builder.rb +0 -154
- data/lib/aws/core/rest_response_parser.rb +0 -66
- data/lib/aws/core/rest_xml_client.rb +0 -47
- data/lib/aws/core/service_interface.rb +0 -83
- data/lib/aws/core/signers/base.rb +0 -46
- data/lib/aws/core/signers/cloud_front.rb +0 -56
- data/lib/aws/core/signers/s3.rb +0 -159
- data/lib/aws/core/signers/version_2.rb +0 -72
- data/lib/aws/core/signers/version_3.rb +0 -86
- data/lib/aws/core/signers/version_3_https.rb +0 -61
- data/lib/aws/core/signers/version_4.rb +0 -228
- data/lib/aws/core/signers/version_4/chunk_signed_stream.rb +0 -191
- data/lib/aws/core/uri_escape.rb +0 -44
- data/lib/aws/core/xml/frame.rb +0 -244
- data/lib/aws/core/xml/frame_stack.rb +0 -85
- data/lib/aws/core/xml/grammar.rb +0 -306
- data/lib/aws/core/xml/parser.rb +0 -70
- data/lib/aws/core/xml/root_frame.rb +0 -65
- data/lib/aws/core/xml/sax_handlers/libxml.rb +0 -47
- data/lib/aws/core/xml/sax_handlers/nokogiri.rb +0 -56
- data/lib/aws/core/xml/sax_handlers/ox.rb +0 -41
- data/lib/aws/core/xml/sax_handlers/rexml.rb +0 -47
- data/lib/aws/core/xml/stub.rb +0 -123
- data/lib/aws/data_pipeline.rb +0 -72
- data/lib/aws/data_pipeline/client.rb +0 -36
- data/lib/aws/data_pipeline/config.rb +0 -18
- data/lib/aws/data_pipeline/errors.rb +0 -20
- data/lib/aws/direct_connect.rb +0 -73
- data/lib/aws/direct_connect/client.rb +0 -36
- data/lib/aws/direct_connect/config.rb +0 -18
- data/lib/aws/direct_connect/errors.rb +0 -22
- data/lib/aws/dynamo_db.rb +0 -214
- data/lib/aws/dynamo_db/attribute_collection.rb +0 -456
- data/lib/aws/dynamo_db/batch_get.rb +0 -213
- data/lib/aws/dynamo_db/batch_write.rb +0 -252
- data/lib/aws/dynamo_db/binary.rb +0 -35
- data/lib/aws/dynamo_db/client.rb +0 -129
- data/lib/aws/dynamo_db/client/v20111205.rb +0 -1266
- data/lib/aws/dynamo_db/client/v20120810.rb +0 -1409
- data/lib/aws/dynamo_db/client_v2.rb +0 -44
- data/lib/aws/dynamo_db/config.rb +0 -24
- data/lib/aws/dynamo_db/errors.rb +0 -20
- data/lib/aws/dynamo_db/expectations.rb +0 -40
- data/lib/aws/dynamo_db/item.rb +0 -133
- data/lib/aws/dynamo_db/item_collection.rb +0 -856
- data/lib/aws/dynamo_db/item_data.rb +0 -31
- data/lib/aws/dynamo_db/keys.rb +0 -41
- data/lib/aws/dynamo_db/primary_key_element.rb +0 -48
- data/lib/aws/dynamo_db/resource.rb +0 -33
- data/lib/aws/dynamo_db/table.rb +0 -496
- data/lib/aws/dynamo_db/table_collection.rb +0 -165
- data/lib/aws/dynamo_db/types.rb +0 -111
- data/lib/aws/ec2.rb +0 -428
- data/lib/aws/ec2/attachment.rb +0 -135
- data/lib/aws/ec2/attachment_collection.rb +0 -54
- data/lib/aws/ec2/availability_zone.rb +0 -86
- data/lib/aws/ec2/availability_zone_collection.rb +0 -43
- data/lib/aws/ec2/block_device_mappings.rb +0 -53
- data/lib/aws/ec2/client.rb +0 -101
- data/lib/aws/ec2/collection.rb +0 -36
- data/lib/aws/ec2/config.rb +0 -30
- data/lib/aws/ec2/customer_gateway.rb +0 -90
- data/lib/aws/ec2/customer_gateway_collection.rb +0 -73
- data/lib/aws/ec2/dhcp_options.rb +0 -106
- data/lib/aws/ec2/dhcp_options_collection.rb +0 -87
- data/lib/aws/ec2/elastic_ip.rb +0 -209
- data/lib/aws/ec2/elastic_ip_collection.rb +0 -93
- data/lib/aws/ec2/errors.rb +0 -32
- data/lib/aws/ec2/export_task.rb +0 -120
- data/lib/aws/ec2/export_task_collection.rb +0 -67
- data/lib/aws/ec2/filtered_collection.rb +0 -87
- data/lib/aws/ec2/has_permissions.rb +0 -44
- data/lib/aws/ec2/image.rb +0 -270
- data/lib/aws/ec2/image_collection.rb +0 -220
- data/lib/aws/ec2/instance.rb +0 -803
- data/lib/aws/ec2/instance_collection.rb +0 -391
- data/lib/aws/ec2/internet_gateway.rb +0 -122
- data/lib/aws/ec2/internet_gateway/attachment.rb +0 -78
- data/lib/aws/ec2/internet_gateway_collection.rb +0 -54
- data/lib/aws/ec2/key_pair.rb +0 -82
- data/lib/aws/ec2/key_pair_collection.rb +0 -99
- data/lib/aws/ec2/network_acl.rb +0 -256
- data/lib/aws/ec2/network_acl/association.rb +0 -56
- data/lib/aws/ec2/network_acl/entry.rb +0 -147
- data/lib/aws/ec2/network_acl_collection.rb +0 -64
- data/lib/aws/ec2/network_interface.rb +0 -237
- data/lib/aws/ec2/network_interface/attachment.rb +0 -100
- data/lib/aws/ec2/network_interface_collection.rb +0 -103
- data/lib/aws/ec2/permission_collection.rb +0 -174
- data/lib/aws/ec2/region.rb +0 -106
- data/lib/aws/ec2/region_collection.rb +0 -51
- data/lib/aws/ec2/reserved_instances.rb +0 -56
- data/lib/aws/ec2/reserved_instances_collection.rb +0 -40
- data/lib/aws/ec2/reserved_instances_offering.rb +0 -60
- data/lib/aws/ec2/reserved_instances_offering_collection.rb +0 -45
- data/lib/aws/ec2/resource.rb +0 -161
- data/lib/aws/ec2/resource_tag_collection.rb +0 -211
- data/lib/aws/ec2/route_table.rb +0 -205
- data/lib/aws/ec2/route_table/association.rb +0 -119
- data/lib/aws/ec2/route_table/route.rb +0 -119
- data/lib/aws/ec2/route_table_collection.rb +0 -72
- data/lib/aws/ec2/security_group.rb +0 -482
- data/lib/aws/ec2/security_group/ip_permission.rb +0 -135
- data/lib/aws/ec2/security_group/ip_permission_collection.rb +0 -82
- data/lib/aws/ec2/security_group_collection.rb +0 -133
- data/lib/aws/ec2/snapshot.rb +0 -143
- data/lib/aws/ec2/snapshot_collection.rb +0 -131
- data/lib/aws/ec2/subnet.rb +0 -161
- data/lib/aws/ec2/subnet_collection.rb +0 -115
- data/lib/aws/ec2/tag.rb +0 -81
- data/lib/aws/ec2/tag_collection.rb +0 -107
- data/lib/aws/ec2/tagged_collection.rb +0 -53
- data/lib/aws/ec2/tagged_item.rb +0 -85
- data/lib/aws/ec2/volume.rb +0 -174
- data/lib/aws/ec2/volume_collection.rb +0 -98
- data/lib/aws/ec2/vpc.rb +0 -166
- data/lib/aws/ec2/vpc_collection.rb +0 -70
- data/lib/aws/ec2/vpn_connection.rb +0 -99
- data/lib/aws/ec2/vpn_connection/telemetry.rb +0 -49
- data/lib/aws/ec2/vpn_connection_collection.rb +0 -96
- data/lib/aws/ec2/vpn_gateway.rb +0 -123
- data/lib/aws/ec2/vpn_gateway/attachment.rb +0 -45
- data/lib/aws/ec2/vpn_gateway_collection.rb +0 -77
- data/lib/aws/elastic_beanstalk.rb +0 -49
- data/lib/aws/elastic_beanstalk/client.rb +0 -36
- data/lib/aws/elastic_beanstalk/config.rb +0 -18
- data/lib/aws/elastic_beanstalk/errors.rb +0 -22
- data/lib/aws/elastic_transcoder.rb +0 -29
- data/lib/aws/elastic_transcoder/client.rb +0 -48
- data/lib/aws/elastic_transcoder/config.rb +0 -18
- data/lib/aws/elastic_transcoder/errors.rb +0 -23
- data/lib/aws/elasticache.rb +0 -49
- data/lib/aws/elasticache/client.rb +0 -35
- data/lib/aws/elasticache/config.rb +0 -18
- data/lib/aws/elasticache/errors.rb +0 -22
- data/lib/aws/elb.rb +0 -66
- data/lib/aws/elb/availability_zone_collection.rb +0 -138
- data/lib/aws/elb/backend_server_policy_collection.rb +0 -139
- data/lib/aws/elb/client.rb +0 -35
- data/lib/aws/elb/config.rb +0 -18
- data/lib/aws/elb/errors.rb +0 -26
- data/lib/aws/elb/instance_collection.rb +0 -168
- data/lib/aws/elb/listener.rb +0 -190
- data/lib/aws/elb/listener_collection.rb +0 -113
- data/lib/aws/elb/listener_opts.rb +0 -45
- data/lib/aws/elb/load_balancer.rb +0 -280
- data/lib/aws/elb/load_balancer_collection.rb +0 -146
- data/lib/aws/elb/load_balancer_policy.rb +0 -93
- data/lib/aws/elb/load_balancer_policy_collection.rb +0 -208
- data/lib/aws/emr.rb +0 -87
- data/lib/aws/emr/client.rb +0 -35
- data/lib/aws/emr/config.rb +0 -18
- data/lib/aws/emr/errors.rb +0 -22
- data/lib/aws/emr/instance_group.rb +0 -138
- data/lib/aws/emr/instance_group_collection.rb +0 -82
- data/lib/aws/emr/job_flow.rb +0 -307
- data/lib/aws/emr/job_flow_collection.rb +0 -185
- data/lib/aws/errors.rb +0 -162
- data/lib/aws/glacier.rb +0 -79
- data/lib/aws/glacier/archive.rb +0 -56
- data/lib/aws/glacier/archive_collection.rb +0 -146
- data/lib/aws/glacier/client.rb +0 -49
- data/lib/aws/glacier/config.rb +0 -19
- data/lib/aws/glacier/errors.rb +0 -22
- data/lib/aws/glacier/resource.rb +0 -30
- data/lib/aws/glacier/vault.rb +0 -145
- data/lib/aws/glacier/vault_collection.rb +0 -75
- data/lib/aws/glacier/vault_notification_configuration.rb +0 -29
- data/lib/aws/iam.rb +0 -408
- data/lib/aws/iam/access_key.rb +0 -185
- data/lib/aws/iam/access_key_collection.rb +0 -128
- data/lib/aws/iam/account_alias_collection.rb +0 -79
- data/lib/aws/iam/client.rb +0 -49
- data/lib/aws/iam/collection.rb +0 -83
- data/lib/aws/iam/config.rb +0 -18
- data/lib/aws/iam/errors.rb +0 -22
- data/lib/aws/iam/group.rb +0 -111
- data/lib/aws/iam/group_collection.rb +0 -132
- data/lib/aws/iam/group_policy_collection.rb +0 -47
- data/lib/aws/iam/group_user_collection.rb +0 -84
- data/lib/aws/iam/login_profile.rb +0 -99
- data/lib/aws/iam/mfa_device.rb +0 -52
- data/lib/aws/iam/mfa_device_collection.rb +0 -127
- data/lib/aws/iam/policy.rb +0 -46
- data/lib/aws/iam/policy_collection.rb +0 -188
- data/lib/aws/iam/resource.rb +0 -62
- data/lib/aws/iam/server_certificate.rb +0 -141
- data/lib/aws/iam/server_certificate_collection.rb +0 -138
- data/lib/aws/iam/signing_certificate.rb +0 -174
- data/lib/aws/iam/signing_certificate_collection.rb +0 -131
- data/lib/aws/iam/user.rb +0 -200
- data/lib/aws/iam/user_collection.rb +0 -133
- data/lib/aws/iam/user_group_collection.rb +0 -98
- data/lib/aws/iam/user_policy.rb +0 -90
- data/lib/aws/iam/user_policy_collection.rb +0 -45
- data/lib/aws/iam/virtual_mfa_device.rb +0 -139
- data/lib/aws/iam/virtual_mfa_device_collection.rb +0 -73
- data/lib/aws/import_export.rb +0 -73
- data/lib/aws/import_export/client.rb +0 -35
- data/lib/aws/import_export/config.rb +0 -19
- data/lib/aws/import_export/errors.rb +0 -22
- data/lib/aws/kinesis.rb +0 -53
- data/lib/aws/kinesis/client.rb +0 -35
- data/lib/aws/kinesis/config.rb +0 -18
- data/lib/aws/kinesis/errors.rb +0 -20
- data/lib/aws/ops_works.rb +0 -29
- data/lib/aws/ops_works/client.rb +0 -35
- data/lib/aws/ops_works/config.rb +0 -18
- data/lib/aws/ops_works/errors.rb +0 -20
- data/lib/aws/rails.rb +0 -195
- data/lib/aws/rds.rb +0 -70
- data/lib/aws/rds/client.rb +0 -42
- data/lib/aws/rds/config.rb +0 -18
- data/lib/aws/rds/db_instance.rb +0 -216
- data/lib/aws/rds/db_instance_collection.rb +0 -75
- data/lib/aws/rds/db_snapshot.rb +0 -163
- data/lib/aws/rds/db_snapshot_collection.rb +0 -89
- data/lib/aws/rds/errors.rb +0 -22
- data/lib/aws/record.rb +0 -139
- data/lib/aws/record/abstract_base.rb +0 -690
- data/lib/aws/record/attributes.rb +0 -388
- data/lib/aws/record/conversion.rb +0 -38
- data/lib/aws/record/dirty_tracking.rb +0 -287
- data/lib/aws/record/errors.rb +0 -143
- data/lib/aws/record/exceptions.rb +0 -51
- data/lib/aws/record/hash_model.rb +0 -204
- data/lib/aws/record/hash_model/attributes.rb +0 -195
- data/lib/aws/record/hash_model/finder_methods.rb +0 -172
- data/lib/aws/record/hash_model/scope.rb +0 -108
- data/lib/aws/record/model.rb +0 -453
- data/lib/aws/record/model/attributes.rb +0 -377
- data/lib/aws/record/model/finder_methods.rb +0 -232
- data/lib/aws/record/model/scope.rb +0 -212
- data/lib/aws/record/naming.rb +0 -31
- data/lib/aws/record/scope.rb +0 -203
- data/lib/aws/record/validations.rb +0 -694
- data/lib/aws/record/validator.rb +0 -246
- data/lib/aws/record/validators/acceptance.rb +0 -49
- data/lib/aws/record/validators/block.rb +0 -36
- data/lib/aws/record/validators/confirmation.rb +0 -41
- data/lib/aws/record/validators/count.rb +0 -106
- data/lib/aws/record/validators/exclusion.rb +0 -41
- data/lib/aws/record/validators/format.rb +0 -55
- data/lib/aws/record/validators/inclusion.rb +0 -54
- data/lib/aws/record/validators/length.rb +0 -105
- data/lib/aws/record/validators/method.rb +0 -31
- data/lib/aws/record/validators/numericality.rb +0 -136
- data/lib/aws/record/validators/presence.rb +0 -43
- data/lib/aws/redshift.rb +0 -51
- data/lib/aws/redshift/client.rb +0 -35
- data/lib/aws/redshift/config.rb +0 -18
- data/lib/aws/redshift/errors.rb +0 -22
- data/lib/aws/route_53.rb +0 -86
- data/lib/aws/route_53/change_batch.rb +0 -161
- data/lib/aws/route_53/change_info.rb +0 -72
- data/lib/aws/route_53/client.rb +0 -35
- data/lib/aws/route_53/config.rb +0 -18
- data/lib/aws/route_53/errors.rb +0 -22
- data/lib/aws/route_53/hosted_zone.rb +0 -111
- data/lib/aws/route_53/hosted_zone_collection.rb +0 -100
- data/lib/aws/route_53/resource_record_set.rb +0 -251
- data/lib/aws/route_53/resource_record_set_collection.rb +0 -110
- data/lib/aws/s3.rb +0 -156
- data/lib/aws/s3/access_control_list.rb +0 -265
- data/lib/aws/s3/acl_object.rb +0 -264
- data/lib/aws/s3/acl_options.rb +0 -204
- data/lib/aws/s3/bucket.rb +0 -742
- data/lib/aws/s3/bucket_collection.rb +0 -162
- data/lib/aws/s3/bucket_lifecycle_configuration.rb +0 -457
- data/lib/aws/s3/bucket_tag_collection.rb +0 -111
- data/lib/aws/s3/bucket_version_collection.rb +0 -79
- data/lib/aws/s3/cipher_io.rb +0 -120
- data/lib/aws/s3/client.rb +0 -1919
- data/lib/aws/s3/client/xml.rb +0 -259
- data/lib/aws/s3/config.rb +0 -48
- data/lib/aws/s3/cors_rule.rb +0 -108
- data/lib/aws/s3/cors_rule_collection.rb +0 -194
- data/lib/aws/s3/data_options.rb +0 -191
- data/lib/aws/s3/encryption_utils.rb +0 -146
- data/lib/aws/s3/errors.rb +0 -94
- data/lib/aws/s3/multipart_upload.rb +0 -351
- data/lib/aws/s3/multipart_upload_collection.rb +0 -76
- data/lib/aws/s3/object_collection.rb +0 -353
- data/lib/aws/s3/object_metadata.rb +0 -103
- data/lib/aws/s3/object_upload_collection.rb +0 -77
- data/lib/aws/s3/object_version.rb +0 -154
- data/lib/aws/s3/object_version_collection.rb +0 -89
- data/lib/aws/s3/paginated_collection.rb +0 -75
- data/lib/aws/s3/policy.rb +0 -74
- data/lib/aws/s3/prefix_and_delimiter_collection.rb +0 -47
- data/lib/aws/s3/prefixed_collection.rb +0 -85
- data/lib/aws/s3/presign_v4.rb +0 -127
- data/lib/aws/s3/presigned_post.rb +0 -554
- data/lib/aws/s3/request.rb +0 -62
- data/lib/aws/s3/s3_object.rb +0 -1781
- data/lib/aws/s3/tree.rb +0 -116
- data/lib/aws/s3/tree/branch_node.rb +0 -68
- data/lib/aws/s3/tree/child_collection.rb +0 -104
- data/lib/aws/s3/tree/leaf_node.rb +0 -94
- data/lib/aws/s3/tree/node.rb +0 -22
- data/lib/aws/s3/tree/parent.rb +0 -87
- data/lib/aws/s3/uploaded_part.rb +0 -82
- data/lib/aws/s3/uploaded_part_collection.rb +0 -84
- data/lib/aws/s3/website_configuration.rb +0 -102
- data/lib/aws/simple_db.rb +0 -218
- data/lib/aws/simple_db/attribute.rb +0 -156
- data/lib/aws/simple_db/attribute_collection.rb +0 -240
- data/lib/aws/simple_db/client.rb +0 -67
- data/lib/aws/simple_db/config.rb +0 -20
- data/lib/aws/simple_db/consistent_read_option.rb +0 -42
- data/lib/aws/simple_db/delete_attributes.rb +0 -62
- data/lib/aws/simple_db/domain.rb +0 -123
- data/lib/aws/simple_db/domain_collection.rb +0 -86
- data/lib/aws/simple_db/domain_metadata.rb +0 -110
- data/lib/aws/simple_db/errors.rb +0 -55
- data/lib/aws/simple_db/expect_condition_option.rb +0 -45
- data/lib/aws/simple_db/item.rb +0 -93
- data/lib/aws/simple_db/item_collection.rb +0 -654
- data/lib/aws/simple_db/item_data.rb +0 -73
- data/lib/aws/simple_db/put_attributes.rb +0 -60
- data/lib/aws/simple_email_service.rb +0 -430
- data/lib/aws/simple_email_service/client.rb +0 -37
- data/lib/aws/simple_email_service/config.rb +0 -18
- data/lib/aws/simple_email_service/email_address_collection.rb +0 -69
- data/lib/aws/simple_email_service/errors.rb +0 -22
- data/lib/aws/simple_email_service/identity.rb +0 -209
- data/lib/aws/simple_email_service/identity_collection.rb +0 -81
- data/lib/aws/simple_email_service/quotas.rb +0 -66
- data/lib/aws/simple_workflow.rb +0 -227
- data/lib/aws/simple_workflow/activity_task.rb +0 -178
- data/lib/aws/simple_workflow/activity_task_collection.rb +0 -123
- data/lib/aws/simple_workflow/activity_type.rb +0 -131
- data/lib/aws/simple_workflow/activity_type_collection.rb +0 -93
- data/lib/aws/simple_workflow/client.rb +0 -69
- data/lib/aws/simple_workflow/config.rb +0 -18
- data/lib/aws/simple_workflow/count.rb +0 -49
- data/lib/aws/simple_workflow/decision_task.rb +0 -603
- data/lib/aws/simple_workflow/decision_task_collection.rb +0 -225
- data/lib/aws/simple_workflow/domain.rb +0 -122
- data/lib/aws/simple_workflow/domain_collection.rb +0 -169
- data/lib/aws/simple_workflow/errors.rb +0 -20
- data/lib/aws/simple_workflow/history_event.rb +0 -276
- data/lib/aws/simple_workflow/history_event_collection.rb +0 -76
- data/lib/aws/simple_workflow/option_formatters.rb +0 -82
- data/lib/aws/simple_workflow/resource.rb +0 -94
- data/lib/aws/simple_workflow/type.rb +0 -89
- data/lib/aws/simple_workflow/type_collection.rb +0 -140
- data/lib/aws/simple_workflow/workflow_execution.rb +0 -384
- data/lib/aws/simple_workflow/workflow_execution_collection.rb +0 -617
- data/lib/aws/simple_workflow/workflow_type.rb +0 -179
- data/lib/aws/simple_workflow/workflow_type_collection.rb +0 -91
- data/lib/aws/sns.rb +0 -76
- data/lib/aws/sns/client.rb +0 -35
- data/lib/aws/sns/config.rb +0 -18
- data/lib/aws/sns/errors.rb +0 -22
- data/lib/aws/sns/has_delivery_policy.rb +0 -68
- data/lib/aws/sns/message.rb +0 -194
- data/lib/aws/sns/originators/from_auto_scaling.rb +0 -68
- data/lib/aws/sns/policy.rb +0 -47
- data/lib/aws/sns/subscription.rb +0 -165
- data/lib/aws/sns/subscription_collection.rb +0 -78
- data/lib/aws/sns/topic.rb +0 -403
- data/lib/aws/sns/topic_collection.rb +0 -62
- data/lib/aws/sns/topic_subscription_collection.rb +0 -54
- data/lib/aws/sqs.rb +0 -80
- data/lib/aws/sqs/client.rb +0 -53
- data/lib/aws/sqs/config.rb +0 -20
- data/lib/aws/sqs/errors.rb +0 -125
- data/lib/aws/sqs/policy.rb +0 -48
- data/lib/aws/sqs/queue.rb +0 -843
- data/lib/aws/sqs/queue_collection.rb +0 -182
- data/lib/aws/sqs/received_message.rb +0 -182
- data/lib/aws/sqs/received_sns_message.rb +0 -116
- data/lib/aws/storage_gateway.rb +0 -72
- data/lib/aws/storage_gateway/client.rb +0 -42
- data/lib/aws/storage_gateway/config.rb +0 -18
- data/lib/aws/storage_gateway/errors.rb +0 -22
- data/lib/aws/sts.rb +0 -164
- data/lib/aws/sts/client.rb +0 -46
- data/lib/aws/sts/config.rb +0 -18
- data/lib/aws/sts/errors.rb +0 -22
- data/lib/aws/sts/federated_session.rb +0 -56
- data/lib/aws/sts/policy.rb +0 -30
- data/lib/aws/sts/session.rb +0 -48
- data/lib/aws/support.rb +0 -29
- data/lib/aws/support/client.rb +0 -35
- data/lib/aws/support/config.rb +0 -18
- data/lib/aws/support/errors.rb +0 -20
- data/lib/aws/version.rb +0 -17
- data/rails/init.rb +0 -15
data/lib/aws/s3/request.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
-
# may not use this file except in compliance with the License. A copy of
|
5
|
-
# the License is located at
|
6
|
-
#
|
7
|
-
# http://aws.amazon.com/apache2.0/
|
8
|
-
#
|
9
|
-
# or in the "license" file accompanying this file. This file is
|
10
|
-
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
-
# ANY KIND, either express or implied. See the License for the specific
|
12
|
-
# language governing permissions and limitations under the License.
|
13
|
-
|
14
|
-
require 'uri'
|
15
|
-
require 'time'
|
16
|
-
|
17
|
-
module AWS
|
18
|
-
class S3
|
19
|
-
|
20
|
-
# @api private
|
21
|
-
class Request < Core::Http::Request
|
22
|
-
|
23
|
-
include Core::UriEscape
|
24
|
-
|
25
|
-
# @return [bucket] S3 bucket name
|
26
|
-
attr_accessor :bucket
|
27
|
-
|
28
|
-
# @return [String] S3 object key
|
29
|
-
attr_accessor :key
|
30
|
-
|
31
|
-
# @api private
|
32
|
-
attr_accessor :force_path_style
|
33
|
-
|
34
|
-
def host
|
35
|
-
path_style? ? @host : "#{bucket}.#{@host}"
|
36
|
-
end
|
37
|
-
|
38
|
-
def path_style?
|
39
|
-
if force_path_style
|
40
|
-
true
|
41
|
-
else
|
42
|
-
Client.path_style_bucket_name?(bucket)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def uri
|
47
|
-
parts = []
|
48
|
-
parts << bucket if bucket and path_style?
|
49
|
-
parts << escape_path(key) if key
|
50
|
-
|
51
|
-
path = '/' + parts.join('/')
|
52
|
-
querystring = url_encoded_params
|
53
|
-
|
54
|
-
uri = ''
|
55
|
-
uri << path
|
56
|
-
uri << "?#{querystring}" if querystring
|
57
|
-
uri
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
data/lib/aws/s3/s3_object.rb
DELETED
@@ -1,1781 +0,0 @@
|
|
1
|
-
# Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
-
# may not use this file except in compliance with the License. A copy of
|
5
|
-
# the License is located at
|
6
|
-
#
|
7
|
-
# http://aws.amazon.com/apache2.0/
|
8
|
-
#
|
9
|
-
# or in the "license" file accompanying this file. This file is
|
10
|
-
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
-
# ANY KIND, either express or implied. See the License for the specific
|
12
|
-
# language governing permissions and limitations under the License.
|
13
|
-
|
14
|
-
require 'uri'
|
15
|
-
require 'base64'
|
16
|
-
|
17
|
-
module AWS
|
18
|
-
class S3
|
19
|
-
|
20
|
-
# Represents an object in S3. Objects live in a bucket and have
|
21
|
-
# unique keys.
|
22
|
-
#
|
23
|
-
# # Getting Objects
|
24
|
-
#
|
25
|
-
# You can get an object by its key.
|
26
|
-
#
|
27
|
-
# s3 = AWS::S3.new
|
28
|
-
# obj = s3.buckets['my-bucket'].objects['key'] # no request made
|
29
|
-
#
|
30
|
-
# You can also get objects by enumerating a objects in a bucket.
|
31
|
-
#
|
32
|
-
# bucket.objects.each do |obj|
|
33
|
-
# puts obj.key
|
34
|
-
# end
|
35
|
-
#
|
36
|
-
# See {ObjectCollection} for more information on finding objects.
|
37
|
-
#
|
38
|
-
# # Creating Objects
|
39
|
-
#
|
40
|
-
# You create an object by writing to it. The following two
|
41
|
-
# expressions are equivalent.
|
42
|
-
#
|
43
|
-
# obj = bucket.objects.create('key', 'data')
|
44
|
-
# obj = bucket.objects['key'].write('data')
|
45
|
-
#
|
46
|
-
# # Writing Objects
|
47
|
-
#
|
48
|
-
# To upload data to S3, you simply need to call {#write} on an object.
|
49
|
-
#
|
50
|
-
# obj.write('Hello World!')
|
51
|
-
# obj.read
|
52
|
-
# #=> 'Hello World!'
|
53
|
-
#
|
54
|
-
# ## Uploading Files
|
55
|
-
#
|
56
|
-
# You can upload a file to S3 in a variety of ways. Given a path
|
57
|
-
# to a file (as a string) you can do any of the following:
|
58
|
-
#
|
59
|
-
# # specify the data as a path to a file
|
60
|
-
# obj.write(Pathname.new(path_to_file))
|
61
|
-
#
|
62
|
-
# # also works this way
|
63
|
-
# obj.write(:file => path_to_file)
|
64
|
-
#
|
65
|
-
# # Also accepts an open file object
|
66
|
-
# file = File.open(path_to_file, 'rb')
|
67
|
-
# obj.write(file)
|
68
|
-
#
|
69
|
-
# All three examples above produce the same result. The file
|
70
|
-
# will be streamed to S3 in chunks. It will not be loaded
|
71
|
-
# entirely into memory.
|
72
|
-
#
|
73
|
-
# ## Streaming Uploads
|
74
|
-
#
|
75
|
-
# When you call {#write} with an IO-like object, it will be streamed
|
76
|
-
# to S3 in chunks.
|
77
|
-
#
|
78
|
-
# While it is possible to determine the size of many IO objects, you may
|
79
|
-
# have to specify the :content_length of your IO object.
|
80
|
-
# If the exact size can not be known, you may provide an
|
81
|
-
# `:estimated_content_length`. Depending on the size (actual or
|
82
|
-
# estimated) of your data, it will be uploaded in a single request or
|
83
|
-
# in multiple requests via {#multipart_upload}.
|
84
|
-
#
|
85
|
-
# You may also stream uploads to S3 using a block:
|
86
|
-
#
|
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
|
-
#
|
92
|
-
# # Reading Objects
|
93
|
-
#
|
94
|
-
# You can read an object directly using {#read}. Be warned, this will
|
95
|
-
# load the entire object into memory and is not recommended for large
|
96
|
-
# objects.
|
97
|
-
#
|
98
|
-
# obj.write('abc')
|
99
|
-
# puts obj.read
|
100
|
-
# #=> abc
|
101
|
-
#
|
102
|
-
# ## Streaming Downloads
|
103
|
-
#
|
104
|
-
# If you want to stream an object from S3, you can pass a block
|
105
|
-
# to {#read}.
|
106
|
-
#
|
107
|
-
# File.open('output', 'wb') do |file|
|
108
|
-
# large_object.read do |chunk|
|
109
|
-
# file.write(chunk)
|
110
|
-
# end
|
111
|
-
# end
|
112
|
-
#
|
113
|
-
# # Encryption
|
114
|
-
#
|
115
|
-
# Amazon S3 can encrypt objects for you service-side. You can also
|
116
|
-
# use client-side encryption.
|
117
|
-
#
|
118
|
-
# ## Server Side Encryption
|
119
|
-
#
|
120
|
-
# You can specify to use server side encryption when writing an object.
|
121
|
-
#
|
122
|
-
# obj.write('data', :server_side_encryption => :aes256)
|
123
|
-
#
|
124
|
-
# You can also make this the default behavior.
|
125
|
-
#
|
126
|
-
# AWS.config(:s3_server_side_encryption => :aes256)
|
127
|
-
#
|
128
|
-
# s3 = AWS::S3.new
|
129
|
-
# s3.buckets['name'].objects['key'].write('abc') # will be encrypted
|
130
|
-
#
|
131
|
-
# ## Client Side Encryption
|
132
|
-
#
|
133
|
-
# Client side encryption utilizes envelope encryption, so that your keys are
|
134
|
-
# never sent to S3. You can use a symetric key or an asymmetric
|
135
|
-
# key pair.
|
136
|
-
#
|
137
|
-
# ### Symmetric Key Encryption
|
138
|
-
#
|
139
|
-
# An AES key is used for symmetric encryption. The key can be 128, 192,
|
140
|
-
# and 256 bit sizes. Start by generating key or read a previously
|
141
|
-
# generated key.
|
142
|
-
#
|
143
|
-
# # generate a new random key
|
144
|
-
# my_key = OpenSSL::Cipher.new("AES-256-ECB").random_key
|
145
|
-
#
|
146
|
-
# # read an existing key from disk
|
147
|
-
# my_key = File.read("my_key.der")
|
148
|
-
#
|
149
|
-
# Now you can encrypt locally and upload the encrypted data to S3.
|
150
|
-
# To do this, you need to provide your key.
|
151
|
-
#
|
152
|
-
# obj = bucket.objects["my-text-object"]
|
153
|
-
#
|
154
|
-
# # encrypt then upload data
|
155
|
-
# obj.write("MY TEXT", :encryption_key => my_key)
|
156
|
-
#
|
157
|
-
# # try read the object without decrypting, oops
|
158
|
-
# obj.read
|
159
|
-
# #=> '.....'
|
160
|
-
#
|
161
|
-
# Lastly, you can download and decrypt by providing the same key.
|
162
|
-
#
|
163
|
-
# obj.read(:encryption_key => my_key)
|
164
|
-
# #=> "MY TEXT"
|
165
|
-
#
|
166
|
-
# ### Asymmetric Key Pair
|
167
|
-
#
|
168
|
-
# A RSA key pair is used for asymmetric encryption. The public key is used
|
169
|
-
# for encryption and the private key is used for decryption. Start
|
170
|
-
# by generating a key.
|
171
|
-
#
|
172
|
-
# my_key = OpenSSL::PKey::RSA.new(1024)
|
173
|
-
#
|
174
|
-
# Provide your key to #write and the data will be encrypted before it
|
175
|
-
# is uploaded. Pass the same key to #read to decrypt the data
|
176
|
-
# when you download it.
|
177
|
-
#
|
178
|
-
# obj = bucket.objects["my-text-object"]
|
179
|
-
#
|
180
|
-
# # encrypt and upload the data
|
181
|
-
# obj.write("MY TEXT", :encryption_key => my_key)
|
182
|
-
#
|
183
|
-
# # download and decrypt the data
|
184
|
-
# obj.read(:encryption_key => my_key)
|
185
|
-
# #=> "MY TEXT"
|
186
|
-
#
|
187
|
-
# ### Configuring storage locations
|
188
|
-
#
|
189
|
-
# By default, encryption materials are stored in the object metadata.
|
190
|
-
# If you prefer, you can store the encryption materials in a separate
|
191
|
-
# object in S3. This object will have the same key + '.instruction'.
|
192
|
-
#
|
193
|
-
# # new object, does not exist yet
|
194
|
-
# obj = bucket.objects["my-text-object"]
|
195
|
-
#
|
196
|
-
# # no instruction file present
|
197
|
-
# bucket.objects['my-text-object.instruction'].exists?
|
198
|
-
# #=> false
|
199
|
-
#
|
200
|
-
# # store the encryption materials in the instruction file
|
201
|
-
# # instead of obj#metadata
|
202
|
-
# obj.write("MY TEXT",
|
203
|
-
# :encryption_key => MY_KEY,
|
204
|
-
# :encryption_materials_location => :instruction_file)
|
205
|
-
#
|
206
|
-
# bucket.objects['my-text-object.instruction'].exists?
|
207
|
-
# #=> true
|
208
|
-
#
|
209
|
-
# If you store the encryption materials in an instruction file, you
|
210
|
-
# must tell #read this or it will fail to find your encryption materials.
|
211
|
-
#
|
212
|
-
# # reading an encrypted file whos materials are stored in an
|
213
|
-
# # instruction file, and not metadata
|
214
|
-
# obj.read(:encryption_key => MY_KEY,
|
215
|
-
# :encryption_materials_location => :instruction_file)
|
216
|
-
#
|
217
|
-
# ### Configuring default behaviors
|
218
|
-
#
|
219
|
-
# You can configure the default key such that it will automatically
|
220
|
-
# encrypt and decrypt for you. You can do this globally or for a
|
221
|
-
# single S3 interface
|
222
|
-
#
|
223
|
-
# # all objects uploaded/downloaded with this s3 object will be
|
224
|
-
# # encrypted/decrypted
|
225
|
-
# s3 = AWS::S3.new(:s3_encryption_key => "MY_KEY")
|
226
|
-
#
|
227
|
-
# # set the key to always encrypt/decrypt
|
228
|
-
# AWS.config(:s3_encryption_key => "MY_KEY")
|
229
|
-
#
|
230
|
-
# You can also configure the default storage location for the encryption
|
231
|
-
# materials.
|
232
|
-
#
|
233
|
-
# AWS.config(:s3_encryption_materials_location => :instruction_file)
|
234
|
-
#
|
235
|
-
class S3Object
|
236
|
-
|
237
|
-
include Core::Model
|
238
|
-
include DataOptions
|
239
|
-
include ACLOptions
|
240
|
-
include AWS::S3::EncryptionUtils
|
241
|
-
|
242
|
-
# @param [Bucket] bucket The bucket this object belongs to.
|
243
|
-
# @param [String] key The object's key.
|
244
|
-
def initialize(bucket, key, opts = {})
|
245
|
-
super
|
246
|
-
@key = key
|
247
|
-
@bucket = bucket
|
248
|
-
end
|
249
|
-
|
250
|
-
# @return [String] The objects unique key
|
251
|
-
attr_reader :key
|
252
|
-
|
253
|
-
# @return [Bucket] The bucket this object is in.
|
254
|
-
attr_reader :bucket
|
255
|
-
|
256
|
-
# @api private
|
257
|
-
def inspect
|
258
|
-
"<#{self.class}:#{bucket.name}/#{key}>"
|
259
|
-
end
|
260
|
-
|
261
|
-
# @return [Boolean] Returns true if the other object belongs to the
|
262
|
-
# same bucket and has the same key.
|
263
|
-
def == other
|
264
|
-
other.kind_of?(S3Object) and other.bucket == bucket and other.key == key
|
265
|
-
end
|
266
|
-
alias_method :eql?, :==
|
267
|
-
|
268
|
-
# @return [Boolean] Returns `true` if the object exists in S3.
|
269
|
-
def exists?
|
270
|
-
head
|
271
|
-
rescue Errors::NoSuchKey => e
|
272
|
-
false
|
273
|
-
else
|
274
|
-
true
|
275
|
-
end
|
276
|
-
|
277
|
-
# Performs a HEAD request against this object and returns an object
|
278
|
-
# with useful information about the object, including:
|
279
|
-
#
|
280
|
-
# * metadata (hash of user-supplied key-value pairs)
|
281
|
-
# * content_length (integer, number of bytes)
|
282
|
-
# * content_type (as sent to S3 when uploading the object)
|
283
|
-
# * etag (typically the object's MD5)
|
284
|
-
# * server_side_encryption (the algorithm used to encrypt the
|
285
|
-
# object on the server side, e.g. `:aes256`)
|
286
|
-
#
|
287
|
-
# @param [Hash] options
|
288
|
-
# @option options [String] :version_id Which version of this object
|
289
|
-
# to make a HEAD request against.
|
290
|
-
# @return A head object response with metadata,
|
291
|
-
# content_length, content_type, etag and server_side_encryption.
|
292
|
-
def head options = {}
|
293
|
-
client.head_object(options.merge(
|
294
|
-
:bucket_name => bucket.name, :key => key))
|
295
|
-
end
|
296
|
-
|
297
|
-
# Returns the object's ETag.
|
298
|
-
#
|
299
|
-
# Generally the ETAG is the MD5 of the object. If the object was
|
300
|
-
# uploaded using multipart upload then this is the MD5 all of the
|
301
|
-
# upload-part-md5s.
|
302
|
-
#
|
303
|
-
# @return [String] Returns the object's ETag
|
304
|
-
def etag
|
305
|
-
head[:etag]
|
306
|
-
end
|
307
|
-
|
308
|
-
# Returns the object's last modified time.
|
309
|
-
#
|
310
|
-
# @return [Time] Returns the object's last modified time.
|
311
|
-
def last_modified
|
312
|
-
head[:last_modified]
|
313
|
-
end
|
314
|
-
|
315
|
-
# @return [Integer] Size of the object in bytes.
|
316
|
-
def content_length
|
317
|
-
head[:content_length]
|
318
|
-
end
|
319
|
-
|
320
|
-
# @note S3 does not compute content-type. It reports the content-type
|
321
|
-
# as was reported during the file upload.
|
322
|
-
# @return [String] Returns the content type as reported by S3,
|
323
|
-
# defaults to an empty string when not provided during upload.
|
324
|
-
def content_type
|
325
|
-
head[:content_type]
|
326
|
-
end
|
327
|
-
|
328
|
-
# @return [DateTime,nil]
|
329
|
-
def expiration_date
|
330
|
-
head[:expiration_date]
|
331
|
-
end
|
332
|
-
|
333
|
-
# @return [String,nil]
|
334
|
-
def expiration_rule_id
|
335
|
-
head[:expiration_rule_id]
|
336
|
-
end
|
337
|
-
|
338
|
-
# @return [Symbol, nil] Returns the algorithm used to encrypt
|
339
|
-
# the object on the server side, or `nil` if SSE was not used
|
340
|
-
# when storing the object.
|
341
|
-
def server_side_encryption
|
342
|
-
head[:server_side_encryption]
|
343
|
-
end
|
344
|
-
|
345
|
-
# @return [true, false] Returns true if the object was stored
|
346
|
-
# using server side encryption.
|
347
|
-
def server_side_encryption?
|
348
|
-
!server_side_encryption.nil?
|
349
|
-
end
|
350
|
-
|
351
|
-
# @return [Boolean] whether a {#restore} operation on the
|
352
|
-
# object is currently being performed on the object.
|
353
|
-
# @see #restore_expiration_date
|
354
|
-
# @since 1.7.2
|
355
|
-
def restore_in_progress?
|
356
|
-
head[:restore_in_progress]
|
357
|
-
end
|
358
|
-
|
359
|
-
# @return [DateTime] the time when the temporarily restored object
|
360
|
-
# will be removed from S3. Note that the original object will remain
|
361
|
-
# available in Glacier.
|
362
|
-
# @return [nil] if the object was not restored from an archived
|
363
|
-
# copy
|
364
|
-
# @since 1.7.2
|
365
|
-
def restore_expiration_date
|
366
|
-
head[:restore_expiration_date]
|
367
|
-
end
|
368
|
-
|
369
|
-
# @return [Boolean] whether the object is a temporary copy of an
|
370
|
-
# archived object in the Glacier storage class.
|
371
|
-
# @since 1.7.2
|
372
|
-
def restored_object?
|
373
|
-
!!head[:restore_expiration_date]
|
374
|
-
end
|
375
|
-
|
376
|
-
# Deletes the object from its S3 bucket.
|
377
|
-
#
|
378
|
-
# @param [Hash] options
|
379
|
-
#
|
380
|
-
# @option [String] :version_id (nil) If present the specified version
|
381
|
-
# of this object will be deleted. Only works for buckets that have
|
382
|
-
# had versioning enabled.
|
383
|
-
#
|
384
|
-
# @option [Boolean] :delete_instruction_file (false) Set this to `true`
|
385
|
-
# if you use client-side encryption and the encryption materials
|
386
|
-
# were stored in a separate object in S3 (key.instruction).
|
387
|
-
#
|
388
|
-
# @option [String] :mfa The serial number and current token code of
|
389
|
-
# the Multi-Factor Authentication (MFA) device for the user. Format
|
390
|
-
# is "SERIAL TOKEN" - with a space between the serial and token.
|
391
|
-
#
|
392
|
-
# @return [nil]
|
393
|
-
def delete options = {}
|
394
|
-
client.delete_object(options.merge(
|
395
|
-
:bucket_name => bucket.name,
|
396
|
-
:key => key))
|
397
|
-
|
398
|
-
if options[:delete_instruction_file]
|
399
|
-
client.delete_object(
|
400
|
-
:bucket_name => bucket.name,
|
401
|
-
:key => key + '.instruction')
|
402
|
-
end
|
403
|
-
|
404
|
-
nil
|
405
|
-
|
406
|
-
end
|
407
|
-
|
408
|
-
# Restores a temporary copy of an archived object from the
|
409
|
-
# Glacier storage tier. After the specified `days`, Amazon
|
410
|
-
# S3 deletes the temporary copy. Note that the object
|
411
|
-
# remains archived; Amazon S3 deletes only the restored copy.
|
412
|
-
#
|
413
|
-
# Restoring an object does not occur immediately. Use
|
414
|
-
# {#restore_in_progress?} to check the status of the operation.
|
415
|
-
#
|
416
|
-
# @option [Integer] :days (1) the number of days to keep the object
|
417
|
-
# @return [Boolean] `true` if a restore can be initiated.
|
418
|
-
# @since 1.7.2
|
419
|
-
def restore options = {}
|
420
|
-
options[:days] ||= 1
|
421
|
-
|
422
|
-
client.restore_object(
|
423
|
-
:bucket_name => bucket.name,
|
424
|
-
:key => key, :days => options[:days])
|
425
|
-
|
426
|
-
true
|
427
|
-
end
|
428
|
-
|
429
|
-
# @option [String] :version_id (nil) If present the metadata object
|
430
|
-
# will be for the specified version.
|
431
|
-
# @return [ObjectMetadata] Returns an instance of ObjectMetadata
|
432
|
-
# representing the metadata for this object.
|
433
|
-
def metadata options = {}
|
434
|
-
options[:config] = config
|
435
|
-
ObjectMetadata.new(self, options)
|
436
|
-
end
|
437
|
-
|
438
|
-
# Returns a collection representing all the object versions
|
439
|
-
# for this object.
|
440
|
-
#
|
441
|
-
# @example
|
442
|
-
#
|
443
|
-
# bucket.versioning_enabled? # => true
|
444
|
-
# version = bucket.objects["mykey"].versions.latest
|
445
|
-
#
|
446
|
-
# @return [ObjectVersionCollection]
|
447
|
-
def versions
|
448
|
-
ObjectVersionCollection.new(self)
|
449
|
-
end
|
450
|
-
|
451
|
-
# Uploads data to the object in S3.
|
452
|
-
#
|
453
|
-
# obj = s3.buckets['bucket-name'].objects['key']
|
454
|
-
#
|
455
|
-
# # strings
|
456
|
-
# obj.write("HELLO")
|
457
|
-
#
|
458
|
-
# # files (by path)
|
459
|
-
# obj.write(Pathname.new('path/to/file.txt'))
|
460
|
-
#
|
461
|
-
# # file objects
|
462
|
-
# obj.write(File.open('path/to/file.txt', 'rb'))
|
463
|
-
#
|
464
|
-
# # IO objects (must respond to #read and #eof?)
|
465
|
-
# obj.write(io)
|
466
|
-
#
|
467
|
-
# ### Multipart Uploads vs Single Uploads
|
468
|
-
#
|
469
|
-
# This method will intelligently choose between uploading the
|
470
|
-
# file in a signal request and using {#multipart_upload}.
|
471
|
-
# You can control this behavior by configuring the thresholds
|
472
|
-
# and you can disable the multipart feature as well.
|
473
|
-
#
|
474
|
-
# # always send the file in a single request
|
475
|
-
# obj.write(file, :single_request => true)
|
476
|
-
#
|
477
|
-
# # upload the file in parts if the total file size exceeds 100MB
|
478
|
-
# obj.write(file, :multipart_threshold => 100 * 1024 * 1024)
|
479
|
-
#
|
480
|
-
# @overload write(data, options = {})
|
481
|
-
#
|
482
|
-
# @param [String,Pathname,File,IO] data The data to upload.
|
483
|
-
# This may be a:
|
484
|
-
# * String
|
485
|
-
# * Pathname
|
486
|
-
# * File
|
487
|
-
# * IO
|
488
|
-
# * Any object that responds to `#read` and `#eof?`.
|
489
|
-
#
|
490
|
-
# @param options [Hash] Additional upload options.
|
491
|
-
#
|
492
|
-
# @option options [Integer] :content_length If provided, this
|
493
|
-
# option must match the total number of bytes written to S3.
|
494
|
-
# This options is *required* when it is not possible to
|
495
|
-
# automatically determine the size of `data`.
|
496
|
-
#
|
497
|
-
# @option options [Integer] :estimated_content_length When uploading
|
498
|
-
# data of unknown content length, you may specify this option to
|
499
|
-
# hint what mode of upload should take place. When
|
500
|
-
# `:estimated_content_length` exceeds the `:multipart_threshold`,
|
501
|
-
# then the data will be uploaded in parts, otherwise it will
|
502
|
-
# be read into memory and uploaded via {Client#put_object}.
|
503
|
-
#
|
504
|
-
# @option options [Boolean] :single_request (false) When `true`,
|
505
|
-
# this method will always upload the data in a single request
|
506
|
-
# (via {Client#put_object}). When `false`, this method will
|
507
|
-
# choose between {Client#put_object} and {#multipart_upload}.
|
508
|
-
#
|
509
|
-
# @option options [Integer] :multipart_threshold (16777216) Specifies
|
510
|
-
# the maximum size (in bytes) of a single-request upload. If the
|
511
|
-
# data exceeds this threshold, it will be uploaded via
|
512
|
-
# {#multipart_upload}. The default threshold is 16MB and can
|
513
|
-
# be configured via AWS.config(:s3_multipart_threshold => ...).
|
514
|
-
#
|
515
|
-
# @option options [Integer] :multipart_min_part_size (5242880) The
|
516
|
-
# minimum size of a part to upload to S3 when using
|
517
|
-
# {#multipart_upload}. S3 will reject parts smaller than 5MB
|
518
|
-
# (except the final part). The default is 5MB and can be
|
519
|
-
# configured via AWS.config(:s3_multipart_min_part_size => ...).
|
520
|
-
#
|
521
|
-
# @option options [Hash] :metadata A hash of metadata to be
|
522
|
-
# included with the object. These will be sent to S3 as
|
523
|
-
# headers prefixed with `x-amz-meta`. Each name, value pair
|
524
|
-
# must conform to US-ASCII.
|
525
|
-
#
|
526
|
-
# @option options [Symbol,String] :acl (:private) A canned access
|
527
|
-
# control policy. Valid values are:
|
528
|
-
#
|
529
|
-
# * `:private`
|
530
|
-
# * `:public_read`
|
531
|
-
# * `:public_read_write`
|
532
|
-
# * `:authenticated_read`
|
533
|
-
# * `:bucket_owner_read`
|
534
|
-
# * `:bucket_owner_full_control`
|
535
|
-
#
|
536
|
-
# @option options [String] :grant_read
|
537
|
-
#
|
538
|
-
# @option options [String] :grant_write
|
539
|
-
#
|
540
|
-
# @option options [String] :grant_read_acp
|
541
|
-
#
|
542
|
-
# @option options [String] :grant_write_acp
|
543
|
-
#
|
544
|
-
# @option options [String] :grant_full_control
|
545
|
-
#
|
546
|
-
# @option options [Boolean] :reduced_redundancy (false) When `true`,
|
547
|
-
# this object will be stored with Reduced Redundancy Storage.
|
548
|
-
#
|
549
|
-
# @option options :cache_control [String] Can be used to specify
|
550
|
-
# caching behavior. See
|
551
|
-
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
|
552
|
-
#
|
553
|
-
# @option options :content_disposition [String] Specifies
|
554
|
-
# presentational information for the object. See
|
555
|
-
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1
|
556
|
-
#
|
557
|
-
# @option options :content_encoding [String] Specifies what
|
558
|
-
# content encodings have been applied to the object and thus
|
559
|
-
# what decoding mechanisms must be applied to obtain the
|
560
|
-
# media-type referenced by the `Content-Type` header field.
|
561
|
-
# See
|
562
|
-
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11
|
563
|
-
#
|
564
|
-
# @option options [String] :content_md5
|
565
|
-
# The base64 encoded content md5 of the data.
|
566
|
-
#
|
567
|
-
# @option options :content_type A standard MIME type
|
568
|
-
# describing the format of the object data.
|
569
|
-
#
|
570
|
-
# @option options [Symbol] :server_side_encryption (nil) If this
|
571
|
-
# option is set, the object will be stored using server side
|
572
|
-
# encryption. The only valid value is `:aes256`, which
|
573
|
-
# specifies that the object should be stored using the AES
|
574
|
-
# encryption algorithm with 256 bit keys. By default, this
|
575
|
-
# option uses the value of the `:s3_server_side_encryption`
|
576
|
-
# option in the current configuration; for more information,
|
577
|
-
# see {AWS.config}.
|
578
|
-
#
|
579
|
-
# @option options [OpenSSL::PKey::RSA, String] :encryption_key
|
580
|
-
# Set this to encrypt the data client-side using envelope
|
581
|
-
# encryption. The key must be an OpenSSL asymmetric key
|
582
|
-
# or a symmetric key string (16, 24 or 32 bytes in length).
|
583
|
-
#
|
584
|
-
# @option options [Symbol] :encryption_materials_location (:metadata)
|
585
|
-
# Set this to `:instruction_file` if you prefer to store the
|
586
|
-
# client-side encryption materials in a separate object in S3
|
587
|
-
# instead of in the object metadata.
|
588
|
-
#
|
589
|
-
# @option options [String] :expires The date and time at which the
|
590
|
-
# object is no longer cacheable.
|
591
|
-
#
|
592
|
-
# @return [S3Object, ObjectVersion] If the bucket has versioning
|
593
|
-
# enabled, this methods returns an {ObjectVersion}, otherwise
|
594
|
-
# this method returns `self`.
|
595
|
-
#
|
596
|
-
def write *args, &block
|
597
|
-
|
598
|
-
options = compute_write_options(*args, &block)
|
599
|
-
|
600
|
-
add_storage_class_option(options)
|
601
|
-
add_sse_options(options)
|
602
|
-
add_cse_options(options)
|
603
|
-
|
604
|
-
if use_multipart?(options)
|
605
|
-
write_with_multipart(options)
|
606
|
-
else
|
607
|
-
write_with_put_object(options)
|
608
|
-
end
|
609
|
-
|
610
|
-
end
|
611
|
-
|
612
|
-
# Performs a multipart upload. Use this if you have specific
|
613
|
-
# needs for how the upload is split into parts, or if you want
|
614
|
-
# to have more control over how the failure of an individual
|
615
|
-
# part upload is handled. Otherwise, {#write} is much simpler
|
616
|
-
# to use.
|
617
|
-
#
|
618
|
-
# Note: After you initiate multipart upload and upload one or
|
619
|
-
# more parts, you must either complete or abort multipart
|
620
|
-
# upload in order to stop getting charged for storage of the
|
621
|
-
# uploaded parts. Only after you either complete or abort
|
622
|
-
# multipart upload, Amazon S3 frees up the parts storage and
|
623
|
-
# stops charging you for the parts storage.
|
624
|
-
#
|
625
|
-
# @example Uploading an object in two parts
|
626
|
-
#
|
627
|
-
# bucket.objects.myobject.multipart_upload do |upload|
|
628
|
-
# upload.add_part("a" * 5242880)
|
629
|
-
# upload.add_part("b" * 2097152)
|
630
|
-
# end
|
631
|
-
#
|
632
|
-
# @example Uploading parts out of order
|
633
|
-
#
|
634
|
-
# bucket.objects.myobject.multipart_upload do |upload|
|
635
|
-
# upload.add_part("b" * 2097152, :part_number => 2)
|
636
|
-
# upload.add_part("a" * 5242880, :part_number => 1)
|
637
|
-
# end
|
638
|
-
#
|
639
|
-
# @example Aborting an upload after parts have been added
|
640
|
-
#
|
641
|
-
# bucket.objects.myobject.multipart_upload do |upload|
|
642
|
-
# upload.add_part("b" * 2097152, :part_number => 2)
|
643
|
-
# upload.abort
|
644
|
-
# end
|
645
|
-
#
|
646
|
-
# @example Starting an upload and completing it later by ID
|
647
|
-
#
|
648
|
-
# upload = bucket.objects.myobject.multipart_upload
|
649
|
-
# upload.add_part("a" * 5242880)
|
650
|
-
# upload.add_part("b" * 2097152)
|
651
|
-
# id = upload.id
|
652
|
-
#
|
653
|
-
# # later or in a different process
|
654
|
-
# upload = bucket.objects.myobject.multipart_uploads[id]
|
655
|
-
# upload.complete(:remote_parts)
|
656
|
-
#
|
657
|
-
# @yieldparam [MultipartUpload] upload A handle to the upload.
|
658
|
-
# {MultipartUpload#close} is called in an `ensure` clause so
|
659
|
-
# that the upload will always be either completed or
|
660
|
-
# aborted.
|
661
|
-
#
|
662
|
-
# @param [Hash] options Options for the upload.
|
663
|
-
#
|
664
|
-
# @option options [Hash] :metadata A hash of metadata to be
|
665
|
-
# included with the object. These will be sent to S3 as
|
666
|
-
# headers prefixed with `x-amz-meta`. Each name, value pair
|
667
|
-
# must conform to US-ASCII.
|
668
|
-
#
|
669
|
-
# @option options [Symbol] :acl (private) A canned access
|
670
|
-
# control policy. Valid values are:
|
671
|
-
#
|
672
|
-
# * `:private`
|
673
|
-
# * `:public_read`
|
674
|
-
# * `:public_read_write`
|
675
|
-
# * `:authenticated_read`
|
676
|
-
# * `:bucket_owner_read`
|
677
|
-
# * `:bucket_owner_full_control`
|
678
|
-
#
|
679
|
-
# @option options [Boolean] :reduced_redundancy (false) If true,
|
680
|
-
# Reduced Redundancy Storage will be enabled for the uploaded
|
681
|
-
# object.
|
682
|
-
#
|
683
|
-
# @option options :cache_control [String] Can be used to specify
|
684
|
-
# caching behavior. See
|
685
|
-
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
|
686
|
-
#
|
687
|
-
# @option options :content_disposition [String] Specifies
|
688
|
-
# presentational information for the object. See
|
689
|
-
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec19.5.1
|
690
|
-
#
|
691
|
-
# @option options :content_encoding [String] Specifies what
|
692
|
-
# content encodings have been applied to the object and thus
|
693
|
-
# what decoding mechanisms must be applied to obtain the
|
694
|
-
# media-type referenced by the `Content-Type` header field.
|
695
|
-
# See
|
696
|
-
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11
|
697
|
-
#
|
698
|
-
# @option options :content_type A standard MIME type
|
699
|
-
# describing the format of the object data.
|
700
|
-
#
|
701
|
-
# @option options [Symbol] :server_side_encryption (nil) If this
|
702
|
-
# option is set, the object will be stored using server side
|
703
|
-
# encryption. The only valid value is `:aes256`, which
|
704
|
-
# specifies that the object should be stored using the AES
|
705
|
-
# encryption algorithm with 256 bit keys. By default, this
|
706
|
-
# option uses the value of the `:s3_server_side_encryption`
|
707
|
-
# option in the current configuration; for more information,
|
708
|
-
# see {AWS.config}.
|
709
|
-
#
|
710
|
-
# @return [S3Object, ObjectVersion] If the bucket has versioning
|
711
|
-
# enabled, returns the {ObjectVersion} representing the
|
712
|
-
# version that was uploaded. If versioning is disabled,
|
713
|
-
# returns self.
|
714
|
-
#
|
715
|
-
def multipart_upload(options = {})
|
716
|
-
|
717
|
-
options = options.dup
|
718
|
-
add_sse_options(options)
|
719
|
-
|
720
|
-
upload = multipart_uploads.create(options)
|
721
|
-
|
722
|
-
if block_given?
|
723
|
-
begin
|
724
|
-
yield(upload)
|
725
|
-
upload.close
|
726
|
-
rescue => e
|
727
|
-
upload.abort
|
728
|
-
raise e
|
729
|
-
end
|
730
|
-
else
|
731
|
-
upload
|
732
|
-
end
|
733
|
-
end
|
734
|
-
|
735
|
-
# @example Abort any in-progress uploads for the object:
|
736
|
-
#
|
737
|
-
# object.multipart_uploads.each(&:abort)
|
738
|
-
#
|
739
|
-
# @return [ObjectUploadCollection] Returns an object representing the
|
740
|
-
# collection of uploads that are in progress for this object.
|
741
|
-
def multipart_uploads
|
742
|
-
ObjectUploadCollection.new(self)
|
743
|
-
end
|
744
|
-
|
745
|
-
# Moves an object to a new key.
|
746
|
-
#
|
747
|
-
# This works by copying the object to a new key and then
|
748
|
-
# deleting the old object. This function returns the
|
749
|
-
# new object once this is done.
|
750
|
-
#
|
751
|
-
# bucket = s3.buckets['old-bucket']
|
752
|
-
# old_obj = bucket.objects['old-key']
|
753
|
-
#
|
754
|
-
# # renaming an object returns a new object
|
755
|
-
# new_obj = old_obj.move_to('new-key')
|
756
|
-
#
|
757
|
-
# old_obj.key #=> 'old-key'
|
758
|
-
# old_obj.exists? #=> false
|
759
|
-
#
|
760
|
-
# new_obj.key #=> 'new-key'
|
761
|
-
# new_obj.exists? #=> true
|
762
|
-
#
|
763
|
-
# If you need to move an object to a different bucket, pass
|
764
|
-
# `:bucket` or `:bucket_name`.
|
765
|
-
#
|
766
|
-
# obj = s3.buckets['old-bucket'].objects['old-key']
|
767
|
-
# obj.move_to('new-key', :bucket_name => 'new_bucket')
|
768
|
-
#
|
769
|
-
# If the copy succeeds, but the then the delete fails, an error
|
770
|
-
# will be raised.
|
771
|
-
#
|
772
|
-
# @param [String] target The key to move this object to.
|
773
|
-
#
|
774
|
-
# @param [Hash] options
|
775
|
-
#
|
776
|
-
# @option (see #copy_to)
|
777
|
-
#
|
778
|
-
# @return [S3Object] Returns a new object with the new key.
|
779
|
-
#
|
780
|
-
def move_to target, options = {}
|
781
|
-
copy = copy_to(target, options)
|
782
|
-
delete
|
783
|
-
copy
|
784
|
-
end
|
785
|
-
alias_method :rename_to, :move_to
|
786
|
-
|
787
|
-
# Copies data from one S3 object to another.
|
788
|
-
#
|
789
|
-
# S3 handles the copy so the clients does not need to fetch the data
|
790
|
-
# and upload it again. You can also change the storage class and
|
791
|
-
# metadata of the object when copying.
|
792
|
-
#
|
793
|
-
# @note This operation does not copy the ACL, storage class
|
794
|
-
# (standard vs. reduced redundancy) or server side encryption
|
795
|
-
# setting from the source object. If you don't specify any of
|
796
|
-
# these options when copying, the object will have the default
|
797
|
-
# values as described below.
|
798
|
-
#
|
799
|
-
# @param [Mixed] source
|
800
|
-
#
|
801
|
-
# @param [Hash] options
|
802
|
-
#
|
803
|
-
# @option options [String] :bucket_name The name of the bucket
|
804
|
-
# the source object can be found in. Defaults to the current
|
805
|
-
# object's bucket.
|
806
|
-
#
|
807
|
-
# @option options [Bucket] :bucket The bucket the source object
|
808
|
-
# can be found in. Defaults to the current object's bucket.
|
809
|
-
#
|
810
|
-
# @option options [Hash] :metadata A hash of metadata to save
|
811
|
-
# with the copied object. Each name, value pair must conform
|
812
|
-
# to US-ASCII. When blank, the sources metadata is copied.
|
813
|
-
# If you set this value, you must set ALL metadata values for
|
814
|
-
# the object as we do not preserve existing values.
|
815
|
-
#
|
816
|
-
# @option options [String] :content_type The content type of
|
817
|
-
# the copied object. Defaults to the source object's content
|
818
|
-
# type.
|
819
|
-
#
|
820
|
-
# @option options [String] :content_disposition The presentational
|
821
|
-
# information for the object. Defaults to the source object's
|
822
|
-
# content disposition.
|
823
|
-
#
|
824
|
-
# @option options [Boolean] :reduced_redundancy (false) If true the
|
825
|
-
# object is stored with reduced redundancy in S3 for a lower cost.
|
826
|
-
#
|
827
|
-
# @option options [String] :version_id (nil) Causes the copy to
|
828
|
-
# read a specific version of the source object.
|
829
|
-
#
|
830
|
-
# @option options [Symbol] :acl (private) A canned access
|
831
|
-
# control policy. Valid values are:
|
832
|
-
#
|
833
|
-
# * `:private`
|
834
|
-
# * `:public_read`
|
835
|
-
# * `:public_read_write`
|
836
|
-
# * `:authenticated_read`
|
837
|
-
# * `:bucket_owner_read`
|
838
|
-
# * `:bucket_owner_full_control`
|
839
|
-
#
|
840
|
-
# @option options [Symbol] :server_side_encryption (nil) If this
|
841
|
-
# option is set, the object will be stored using server side
|
842
|
-
# encryption. The only valid value is `:aes256`, which
|
843
|
-
# specifies that the object should be stored using the AES
|
844
|
-
# encryption algorithm with 256 bit keys. By default, this
|
845
|
-
# option uses the value of the `:s3_server_side_encryption`
|
846
|
-
# option in the current configuration; for more information,
|
847
|
-
# see {AWS.config}.
|
848
|
-
#
|
849
|
-
# @option options [Boolean] :client_side_encrypted (false) Set to true
|
850
|
-
# when the object being copied was client-side encrypted. This
|
851
|
-
# is important so the encryption metadata will be copied.
|
852
|
-
#
|
853
|
-
# @option options [Boolean] :use_multipart_copy (false) Set this to
|
854
|
-
# `true` if you need to copy an object that is larger than 5GB.
|
855
|
-
#
|
856
|
-
# @option options :cache_control [String] Can be used to specify
|
857
|
-
# caching behavior. See
|
858
|
-
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
|
859
|
-
#
|
860
|
-
# @option options [String] :expires The date and time at which the
|
861
|
-
# object is no longer cacheable.
|
862
|
-
#
|
863
|
-
# @return [nil]
|
864
|
-
def copy_from source, options = {}
|
865
|
-
|
866
|
-
options = options.dup
|
867
|
-
|
868
|
-
options[:copy_source] =
|
869
|
-
case source
|
870
|
-
when S3Object
|
871
|
-
"#{source.bucket.name}/#{source.key}"
|
872
|
-
when ObjectVersion
|
873
|
-
options[:version_id] = source.version_id
|
874
|
-
"#{source.object.bucket.name}/#{source.object.key}"
|
875
|
-
else
|
876
|
-
if options[:bucket]
|
877
|
-
"#{options.delete(:bucket).name}/#{source}"
|
878
|
-
elsif options[:bucket_name]
|
879
|
-
"#{options.delete(:bucket_name)}/#{source}"
|
880
|
-
else
|
881
|
-
"#{self.bucket.name}/#{source}"
|
882
|
-
end
|
883
|
-
end
|
884
|
-
|
885
|
-
if [:metadata, :content_disposition, :content_type, :cache_control,
|
886
|
-
].any? {|opt| options.key?(opt) }
|
887
|
-
then
|
888
|
-
options[:metadata_directive] = 'REPLACE'
|
889
|
-
else
|
890
|
-
options[:metadata_directive] ||= 'COPY'
|
891
|
-
end
|
892
|
-
|
893
|
-
# copies client-side encryption materials (from the metadata or
|
894
|
-
# instruction file)
|
895
|
-
if options.delete(:client_side_encrypted)
|
896
|
-
copy_cse_materials(source, options)
|
897
|
-
end
|
898
|
-
|
899
|
-
add_sse_options(options)
|
900
|
-
|
901
|
-
options[:storage_class] = options.delete(:reduced_redundancy) ?
|
902
|
-
'REDUCED_REDUNDANCY' : 'STANDARD'
|
903
|
-
|
904
|
-
options[:bucket_name] = bucket.name
|
905
|
-
options[:key] = key
|
906
|
-
|
907
|
-
if use_multipart_copy?(options)
|
908
|
-
multipart_copy(options)
|
909
|
-
else
|
910
|
-
resp = client.copy_object(options)
|
911
|
-
end
|
912
|
-
|
913
|
-
nil
|
914
|
-
|
915
|
-
end
|
916
|
-
|
917
|
-
# Copies data from the current object to another object in S3.
|
918
|
-
#
|
919
|
-
# S3 handles the copy so the client does not need to fetch the data
|
920
|
-
# and upload it again. You can also change the storage class and
|
921
|
-
# metadata of the object when copying.
|
922
|
-
#
|
923
|
-
# @note This operation does not copy the ACL, storage class
|
924
|
-
# (standard vs. reduced redundancy) or server side encryption
|
925
|
-
# setting from this object to the new object. If you don't
|
926
|
-
# specify any of these options when copying, the new object
|
927
|
-
# will have the default values as described below.
|
928
|
-
#
|
929
|
-
# @param [S3Object,String] target An S3Object, or a string key of
|
930
|
-
# and object to copy to.
|
931
|
-
#
|
932
|
-
# @param [Hash] options
|
933
|
-
#
|
934
|
-
# @option options [String] :bucket_name The name of the bucket
|
935
|
-
# the object should be copied into. Defaults to the current object's
|
936
|
-
# bucket.
|
937
|
-
#
|
938
|
-
# @option options [Bucket] :bucket The bucket the target object
|
939
|
-
# should be copied into. Defaults to the current object's bucket.
|
940
|
-
#
|
941
|
-
# @option options [Hash] :metadata A hash of metadata to save
|
942
|
-
# with the copied object. Each name, value pair must conform
|
943
|
-
# to US-ASCII. When blank, the sources metadata is copied.
|
944
|
-
#
|
945
|
-
# @option options [Boolean] :reduced_redundancy (false) If true
|
946
|
-
# the object is stored with reduced redundancy in S3 for a
|
947
|
-
# lower cost.
|
948
|
-
#
|
949
|
-
# @option options [Symbol] :acl (private) A canned access
|
950
|
-
# control policy. Valid values are:
|
951
|
-
#
|
952
|
-
# * `:private`
|
953
|
-
# * `:public_read`
|
954
|
-
# * `:public_read_write`
|
955
|
-
# * `:authenticated_read`
|
956
|
-
# * `:bucket_owner_read`
|
957
|
-
# * `:bucket_owner_full_control`
|
958
|
-
#
|
959
|
-
# @option options [Symbol] :server_side_encryption (nil) If this
|
960
|
-
# option is set, the object will be stored using server side
|
961
|
-
# encryption. The only valid value is `:aes256`, which
|
962
|
-
# specifies that the object should be stored using the AES
|
963
|
-
# encryption algorithm with 256 bit keys. By default, this
|
964
|
-
# option uses the value of the `:s3_server_side_encryption`
|
965
|
-
# option in the current configuration; for more information,
|
966
|
-
# see {AWS.config}.
|
967
|
-
#
|
968
|
-
# @option options [Boolean] :client_side_encrypted (false) When `true`,
|
969
|
-
# the client-side encryption materials will be copied. Without this
|
970
|
-
# option, the key and iv are not guaranteed to be transferred to
|
971
|
-
# the new object.
|
972
|
-
#
|
973
|
-
# @option options [String] :expires The date and time at which the
|
974
|
-
# object is no longer cacheable.
|
975
|
-
#
|
976
|
-
# @return [S3Object] Returns the copy (target) object.
|
977
|
-
#
|
978
|
-
def copy_to target, options = {}
|
979
|
-
|
980
|
-
unless target.is_a?(S3Object)
|
981
|
-
|
982
|
-
bucket = case
|
983
|
-
when options[:bucket] then options[:bucket]
|
984
|
-
when options[:bucket_name]
|
985
|
-
Bucket.new(options[:bucket_name], :config => config)
|
986
|
-
else self.bucket
|
987
|
-
end
|
988
|
-
|
989
|
-
target = S3Object.new(bucket, target)
|
990
|
-
end
|
991
|
-
|
992
|
-
copy_opts = options.dup
|
993
|
-
copy_opts.delete(:bucket)
|
994
|
-
copy_opts.delete(:bucket_name)
|
995
|
-
|
996
|
-
target.copy_from(self, copy_opts)
|
997
|
-
target
|
998
|
-
|
999
|
-
end
|
1000
|
-
|
1001
|
-
# Fetches the object data from S3. If you pass a block to this
|
1002
|
-
# method, the data will be yielded to the block in chunks as it
|
1003
|
-
# is read off the HTTP response.
|
1004
|
-
#
|
1005
|
-
# ### Read an object from S3 in chunks
|
1006
|
-
#
|
1007
|
-
# When downloading large objects it is recommended to pass a block
|
1008
|
-
# to #read. Data will be yielded to the block as it is read off
|
1009
|
-
# the HTTP response.
|
1010
|
-
#
|
1011
|
-
# # read an object from S3 to a file
|
1012
|
-
# File.open('output.txt', 'wb') do |file|
|
1013
|
-
# bucket.objects['key'].read do |chunk|
|
1014
|
-
# file.write(chunk)
|
1015
|
-
# end
|
1016
|
-
# end
|
1017
|
-
#
|
1018
|
-
# ### Reading an object without a block
|
1019
|
-
#
|
1020
|
-
# When you omit the block argument to #read, then the entire
|
1021
|
-
# HTTP response and read and the object data is loaded into
|
1022
|
-
# memory.
|
1023
|
-
#
|
1024
|
-
# bucket.objects['key'].read
|
1025
|
-
# #=> 'object-contents-here'
|
1026
|
-
#
|
1027
|
-
# @param [Hash] options
|
1028
|
-
#
|
1029
|
-
# @option options [String] :version_id Reads data from a
|
1030
|
-
# specific version of this object.
|
1031
|
-
#
|
1032
|
-
# @option options [Time] :if_unmodified_since If specified, the
|
1033
|
-
# method will raise
|
1034
|
-
# `AWS::S3::Errors::PreconditionFailed` unless the
|
1035
|
-
# object has not been modified since the given time.
|
1036
|
-
#
|
1037
|
-
# @option options [Time] :if_modified_since If specified, the
|
1038
|
-
# method will raise `AWS::S3::Errors::NotModified` if
|
1039
|
-
# the object has not been modified since the given time.
|
1040
|
-
#
|
1041
|
-
# @option options [String] :if_match If specified, the method
|
1042
|
-
# will raise `AWS::S3::Errors::PreconditionFailed`
|
1043
|
-
# unless the object ETag matches the provided value.
|
1044
|
-
#
|
1045
|
-
# @option options [String] :if_none_match If specified, the
|
1046
|
-
# method will raise `AWS::S3::Errors::NotModified` if
|
1047
|
-
# the object ETag matches the provided value.
|
1048
|
-
#
|
1049
|
-
# @option options [Range] :range A byte range to read data from
|
1050
|
-
#
|
1051
|
-
# @option options [OpenSSL::PKey::RSA, String] :encryption_key
|
1052
|
-
# (nil) If this option is set, the object will be decrypted using
|
1053
|
-
# envelope encryption. The valid values are OpenSSL asymmetric keys
|
1054
|
-
# `OpenSSL::Pkey::RSA` or strings representing symmetric keys
|
1055
|
-
# of an AES-128/192/256-ECB cipher as a `String`.
|
1056
|
-
# This value defaults to the value in `s3_encryption_key`;
|
1057
|
-
# for more information, see {AWS.config}.
|
1058
|
-
#
|
1059
|
-
# Symmetric Keys:
|
1060
|
-
#
|
1061
|
-
# cipher = OpenSSL::Cipher.new('AES-256-ECB')
|
1062
|
-
# key = cipher.random_key
|
1063
|
-
#
|
1064
|
-
# Asymmetric keys can also be generated as so:
|
1065
|
-
# key = OpenSSL::PKey::RSA.new(KEY_SIZE)
|
1066
|
-
#
|
1067
|
-
# @option options [Symbol] :encryption_materials_location (:metadata)
|
1068
|
-
# Set this to `:instruction_file` if the encryption materials
|
1069
|
-
# are not stored in the object metadata
|
1070
|
-
#
|
1071
|
-
# @note `:range` option cannot be used with client-side encryption
|
1072
|
-
#
|
1073
|
-
# @note All decryption reads incur at least an extra HEAD operation.
|
1074
|
-
#
|
1075
|
-
def read options = {}, &read_block
|
1076
|
-
|
1077
|
-
options[:bucket_name] = bucket.name
|
1078
|
-
options[:key] = key
|
1079
|
-
|
1080
|
-
if should_decrypt?(options)
|
1081
|
-
get_encrypted_object(options, &read_block)
|
1082
|
-
else
|
1083
|
-
resp_data = get_object(options, &read_block)
|
1084
|
-
block_given? ? resp_data : resp_data[:data]
|
1085
|
-
end
|
1086
|
-
|
1087
|
-
end
|
1088
|
-
|
1089
|
-
# @api private
|
1090
|
-
module ACLProxy
|
1091
|
-
|
1092
|
-
attr_accessor :object
|
1093
|
-
|
1094
|
-
def change
|
1095
|
-
yield(self)
|
1096
|
-
object.acl = self
|
1097
|
-
end
|
1098
|
-
|
1099
|
-
end
|
1100
|
-
|
1101
|
-
# Returns the object's access control list. This will be an
|
1102
|
-
# instance of AccessControlList, plus an additional `change`
|
1103
|
-
# method:
|
1104
|
-
#
|
1105
|
-
# object.acl.change do |acl|
|
1106
|
-
# # remove any grants to someone other than the bucket owner
|
1107
|
-
# owner_id = object.bucket.owner.id
|
1108
|
-
# acl.grants.reject! do |g|
|
1109
|
-
# g.grantee.canonical_user_id != owner_id
|
1110
|
-
# end
|
1111
|
-
# end
|
1112
|
-
#
|
1113
|
-
# Note that changing the ACL is not an atomic operation; it
|
1114
|
-
# fetches the current ACL, yields it to the block, and then
|
1115
|
-
# sets it again. Therefore, it's possible that you may
|
1116
|
-
# overwrite a concurrent update to the ACL using this
|
1117
|
-
# method.
|
1118
|
-
#
|
1119
|
-
# @return [AccessControlList]
|
1120
|
-
#
|
1121
|
-
def acl
|
1122
|
-
|
1123
|
-
resp = client.get_object_acl(:bucket_name => bucket.name, :key => key)
|
1124
|
-
|
1125
|
-
acl = AccessControlList.new(resp.data)
|
1126
|
-
acl.extend ACLProxy
|
1127
|
-
acl.object = self
|
1128
|
-
acl
|
1129
|
-
|
1130
|
-
end
|
1131
|
-
|
1132
|
-
# Sets the objects's ACL (access control list). You can provide an ACL
|
1133
|
-
# in a number of different formats.
|
1134
|
-
# @param (see ACLOptions#acl_options)
|
1135
|
-
# @return [nil]
|
1136
|
-
def acl=(acl)
|
1137
|
-
|
1138
|
-
client_opts = {}
|
1139
|
-
client_opts[:bucket_name] = bucket.name
|
1140
|
-
client_opts[:key] = key
|
1141
|
-
|
1142
|
-
client.put_object_acl(acl_options(acl).merge(client_opts))
|
1143
|
-
nil
|
1144
|
-
|
1145
|
-
end
|
1146
|
-
|
1147
|
-
# @api private
|
1148
|
-
REQUEST_PARAMETERS = Core::Signers::S3::QUERY_PARAMS.map do |p|
|
1149
|
-
p.tr("-","_").to_sym
|
1150
|
-
end
|
1151
|
-
|
1152
|
-
# Generates a presigned URL for an operation on this object.
|
1153
|
-
# This URL can be used by a regular HTTP client to perform the
|
1154
|
-
# desired operation without credentials and without changing
|
1155
|
-
# the permissions of the object.
|
1156
|
-
#
|
1157
|
-
# @example Generate a url to read an object
|
1158
|
-
#
|
1159
|
-
# bucket.objects.myobject.url_for(:read)
|
1160
|
-
#
|
1161
|
-
# @example Generate a url to delete an object
|
1162
|
-
#
|
1163
|
-
# bucket.objects.myobject.url_for(:delete)
|
1164
|
-
#
|
1165
|
-
# @example Override response headers for reading an object
|
1166
|
-
#
|
1167
|
-
# object = bucket.objects.myobject
|
1168
|
-
# url = object.url_for(:read,
|
1169
|
-
# :response_content_type => "application/json")
|
1170
|
-
#
|
1171
|
-
# @example Generate a url that expires in 10 minutes
|
1172
|
-
#
|
1173
|
-
# bucket.objects.myobject.url_for(:read, :expires => 10*60)
|
1174
|
-
#
|
1175
|
-
# @param [Symbol, String] method The HTTP verb or object
|
1176
|
-
# method for which the returned URL will be valid. Valid
|
1177
|
-
# values:
|
1178
|
-
#
|
1179
|
-
# * `:get` or `:read`
|
1180
|
-
# * `:put` or `:write`
|
1181
|
-
# * `:delete`
|
1182
|
-
#
|
1183
|
-
# @param [Hash] options Additional options for generating the URL.
|
1184
|
-
#
|
1185
|
-
# @option options :expires Sets the expiration time of the
|
1186
|
-
# URL; after this time S3 will return an error if the URL is
|
1187
|
-
# used. This can be an integer (to specify the number of
|
1188
|
-
# seconds after the current time), a string (which is parsed
|
1189
|
-
# as a date using Time#parse), a Time, or a DateTime object.
|
1190
|
-
# This option defaults to one hour after the current time.
|
1191
|
-
#
|
1192
|
-
# @option options [Boolean] :secure (true) Whether to generate a
|
1193
|
-
# secure (HTTPS) URL or a plain HTTP url.
|
1194
|
-
#
|
1195
|
-
# @option options [String] :content_type Object content type for
|
1196
|
-
# HTTP PUT. When provided, has to be also added to the request
|
1197
|
-
# header as a 'content-type' field
|
1198
|
-
#
|
1199
|
-
# @option options [String] :content_md5 Object MD5 hash for HTTP PUT.
|
1200
|
-
# When provided, has to be also added to the request header as a
|
1201
|
-
# 'content-md5' field
|
1202
|
-
#
|
1203
|
-
# @option options [String] :endpoint Sets the hostname of the
|
1204
|
-
# endpoint.
|
1205
|
-
#
|
1206
|
-
# @option options [Integer] :port Sets the port of the
|
1207
|
-
# endpoint (overrides config.s3_port).
|
1208
|
-
#
|
1209
|
-
# @option options [Boolean] :force_path_style (false) Indicates
|
1210
|
-
# whether the generated URL should place the bucket name in
|
1211
|
-
# the path (true) or as a subdomain (false).
|
1212
|
-
#
|
1213
|
-
# @option options [String] :response_content_type Sets the
|
1214
|
-
# Content-Type header of the response when performing an
|
1215
|
-
# HTTP GET on the returned URL.
|
1216
|
-
#
|
1217
|
-
# @option options [String] :response_content_language Sets the
|
1218
|
-
# Content-Language header of the response when performing an
|
1219
|
-
# HTTP GET on the returned URL.
|
1220
|
-
#
|
1221
|
-
# @option options [String] :response_expires Sets the Expires
|
1222
|
-
# header of the response when performing an HTTP GET on the
|
1223
|
-
# returned URL.
|
1224
|
-
#
|
1225
|
-
# @option options [String] :response_cache_control Sets the
|
1226
|
-
# Cache-Control header of the response when performing an
|
1227
|
-
# HTTP GET on the returned URL.
|
1228
|
-
#
|
1229
|
-
# @option options [String] :response_content_disposition Sets
|
1230
|
-
# the Content-Disposition header of the response when
|
1231
|
-
# performing an HTTP GET on the returned URL.
|
1232
|
-
#
|
1233
|
-
# @option options [String] :acl The value to use for the
|
1234
|
-
# x-amz-acl.
|
1235
|
-
#
|
1236
|
-
# @option options [String] :response_content_encoding Sets the
|
1237
|
-
# Content-Encoding header of the response when performing an
|
1238
|
-
# HTTP GET on the returned URL.
|
1239
|
-
#
|
1240
|
-
# @option options [:v3, :v4] :signature_version (:v3)
|
1241
|
-
#
|
1242
|
-
# @return [URI::HTTP, URI::HTTPS]
|
1243
|
-
def url_for(method, options = {})
|
1244
|
-
|
1245
|
-
options = options.dup
|
1246
|
-
options[:expires] = expiration_timestamp(options[:expires])
|
1247
|
-
options[:secure] = config.use_ssl? unless options.key?(:secure)
|
1248
|
-
options[:signature_version] ||= config.s3_signature_version
|
1249
|
-
|
1250
|
-
case options[:signature_version]
|
1251
|
-
when :v3 then presign_v3(method, options)
|
1252
|
-
when :v4 then presign_v4(method, options)
|
1253
|
-
else
|
1254
|
-
msg = "invalid signature version, expected :v3 or :v4, got "
|
1255
|
-
msg << options[:signature_version].inspect
|
1256
|
-
raise ArgumentError, msg
|
1257
|
-
end
|
1258
|
-
end
|
1259
|
-
|
1260
|
-
# Generates a public (not authenticated) URL for the object.
|
1261
|
-
#
|
1262
|
-
# @param [Hash] options Options for generating the URL.
|
1263
|
-
#
|
1264
|
-
# @option options [Boolean] :secure Whether to generate a
|
1265
|
-
# secure (HTTPS) URL or a plain HTTP url.
|
1266
|
-
#
|
1267
|
-
# @return [URI::HTTP, URI::HTTPS]
|
1268
|
-
#
|
1269
|
-
def public_url(options = {})
|
1270
|
-
options[:secure] = config.use_ssl? unless options.key?(:secure)
|
1271
|
-
build_uri(request_for_signing(options), options)
|
1272
|
-
end
|
1273
|
-
|
1274
|
-
# Generates fields for a presigned POST to this object. This
|
1275
|
-
# method adds a constraint that the key must match the key of
|
1276
|
-
# this object. All options are sent to the PresignedPost
|
1277
|
-
# constructor.
|
1278
|
-
#
|
1279
|
-
# @see PresignedPost
|
1280
|
-
# @return [PresignedPost]
|
1281
|
-
def presigned_post(options = {})
|
1282
|
-
PresignedPost.new(bucket, options.merge(:key => key))
|
1283
|
-
end
|
1284
|
-
|
1285
|
-
# @note Changing the storage class of an object incurs a COPY
|
1286
|
-
# operation.
|
1287
|
-
#
|
1288
|
-
# Changes the storage class of the object to enable or disable
|
1289
|
-
# Reduced Redundancy Storage (RRS).
|
1290
|
-
#
|
1291
|
-
# @param [true,false] value If this is true, the object will be
|
1292
|
-
# copied in place and stored with reduced redundancy at a
|
1293
|
-
# lower cost. Otherwise, the object will be copied and stored
|
1294
|
-
# with the standard storage class.
|
1295
|
-
#
|
1296
|
-
# @return [true,false] The `value` parameter.
|
1297
|
-
def reduced_redundancy= value
|
1298
|
-
copy_from(key, :reduced_redundancy => value)
|
1299
|
-
value
|
1300
|
-
end
|
1301
|
-
|
1302
|
-
private
|
1303
|
-
|
1304
|
-
def presign_v4(method, options)
|
1305
|
-
PresignV4.new(self).presign(method, options)
|
1306
|
-
end
|
1307
|
-
|
1308
|
-
def presign_v3(method, options)
|
1309
|
-
options[:acl] = options[:acl].to_s.sub('_', '-') if options[:acl]
|
1310
|
-
|
1311
|
-
req = request_for_signing(options)
|
1312
|
-
req.http_method = http_method(method)
|
1313
|
-
req.add_param("AWSAccessKeyId", config.credential_provider.access_key_id)
|
1314
|
-
req.add_param("versionId", options[:version_id]) if options[:version_id]
|
1315
|
-
req.add_param("Signature", signature(req, options))
|
1316
|
-
req.add_param("Expires", options[:expires])
|
1317
|
-
req.add_param("x-amz-acl", options[:acl]) if options[:acl]
|
1318
|
-
if config.credential_provider.session_token
|
1319
|
-
req.add_param(
|
1320
|
-
"x-amz-security-token",
|
1321
|
-
config.credential_provider.session_token
|
1322
|
-
)
|
1323
|
-
end
|
1324
|
-
|
1325
|
-
build_uri(req, options)
|
1326
|
-
end
|
1327
|
-
|
1328
|
-
# Used to determine if the data needs to be copied in parts
|
1329
|
-
def use_multipart_copy? options
|
1330
|
-
options[:use_multipart_copy]
|
1331
|
-
end
|
1332
|
-
|
1333
|
-
def multipart_copy options
|
1334
|
-
|
1335
|
-
unless options[:content_length]
|
1336
|
-
msg = "unknown content length, must set :content_length " +
|
1337
|
-
"to use multi-part copy"
|
1338
|
-
raise ArgumentError, msg
|
1339
|
-
end
|
1340
|
-
|
1341
|
-
part_size = compute_part_size(options)
|
1342
|
-
clean_up_options(options)
|
1343
|
-
source_length = options.delete(:content_length)
|
1344
|
-
|
1345
|
-
multipart_upload(options) do |upload|
|
1346
|
-
pos = 0
|
1347
|
-
# We copy in part_size chunks until we read the
|
1348
|
-
until pos >= source_length
|
1349
|
-
last_byte = (pos + part_size >= source_length) ? source_length - 1 : pos + part_size - 1
|
1350
|
-
upload.copy_part(options[:copy_source], options.merge({:copy_source_range => "bytes=#{pos}-#{last_byte}"}))
|
1351
|
-
pos += part_size
|
1352
|
-
end
|
1353
|
-
end
|
1354
|
-
end
|
1355
|
-
|
1356
|
-
# @return [Boolean]
|
1357
|
-
def should_decrypt? options
|
1358
|
-
options[:encryption_key] or config.s3_encryption_key
|
1359
|
-
end
|
1360
|
-
|
1361
|
-
# A small wrapper around client#get_object
|
1362
|
-
def get_object options, &read_block
|
1363
|
-
client.get_object(options, &read_block).data
|
1364
|
-
end
|
1365
|
-
|
1366
|
-
# A wrapper around get_object that decrypts
|
1367
|
-
def get_encrypted_object options, &read_block
|
1368
|
-
decryption_cipher(options) do |cipher|
|
1369
|
-
if block_given?
|
1370
|
-
resp = get_object(options) do |chunk|
|
1371
|
-
yield(cipher.update(chunk))
|
1372
|
-
end
|
1373
|
-
yield(cipher.final)
|
1374
|
-
resp
|
1375
|
-
else
|
1376
|
-
cipher.update(get_object(options)[:data]) + cipher.final
|
1377
|
-
end
|
1378
|
-
end
|
1379
|
-
end
|
1380
|
-
|
1381
|
-
# @return [Boolean] Returns `true` if the :data option is large or
|
1382
|
-
# guessed to be larger than a configured threshold.
|
1383
|
-
def use_multipart? options
|
1384
|
-
estimated_content_length(options) > multipart_threshold(options) and
|
1385
|
-
!options[:single_request]
|
1386
|
-
end
|
1387
|
-
|
1388
|
-
# @return [Integer] Returns the number of bytes where a multipart
|
1389
|
-
# upload is used instead of #put_object.
|
1390
|
-
def multipart_threshold options
|
1391
|
-
threshold = options[:multipart_threshold] ||
|
1392
|
-
config.s3_multipart_threshold
|
1393
|
-
end
|
1394
|
-
|
1395
|
-
# @return [Integer] Returns the size of each multipart chunk.
|
1396
|
-
def compute_part_size options
|
1397
|
-
|
1398
|
-
max_parts = options[:multipart_max_parts] ||
|
1399
|
-
config.s3_multipart_max_parts
|
1400
|
-
|
1401
|
-
min_size = options[:multipart_min_part_size] ||
|
1402
|
-
config.s3_multipart_min_part_size
|
1403
|
-
|
1404
|
-
estimated_size = estimated_content_length(options)
|
1405
|
-
|
1406
|
-
part_size = [(estimated_size.to_f / max_parts).ceil, min_size].max.to_i
|
1407
|
-
part_size += 16 - (part_size % 16)
|
1408
|
-
part_size
|
1409
|
-
|
1410
|
-
end
|
1411
|
-
|
1412
|
-
# @return [Integer] Returns the size of the data or an estimated
|
1413
|
-
# size as provided by the user (useful for IO streams).
|
1414
|
-
def estimated_content_length options
|
1415
|
-
estimate = options[:content_length] ||
|
1416
|
-
options[:estimated_content_length]
|
1417
|
-
unless estimate
|
1418
|
-
msg = "unknown content length, must set :content_length or " +
|
1419
|
-
":estimated_content_length"
|
1420
|
-
raise ArgumentError, msg
|
1421
|
-
end
|
1422
|
-
estimate
|
1423
|
-
end
|
1424
|
-
|
1425
|
-
def build_uri(request, options)
|
1426
|
-
uri_class = options[:secure] ? URI::HTTPS : URI::HTTP
|
1427
|
-
uri_class.build(:host => request.host,
|
1428
|
-
:port => request.port,
|
1429
|
-
:path => request.path,
|
1430
|
-
:query => request.querystring)
|
1431
|
-
end
|
1432
|
-
|
1433
|
-
def signature request, options
|
1434
|
-
parts = []
|
1435
|
-
parts << request.http_method
|
1436
|
-
parts << options[:content_md5].to_s
|
1437
|
-
parts << options[:content_type].to_s
|
1438
|
-
parts << options[:expires]
|
1439
|
-
parts << "x-amz-acl:#{options[:acl]}" if options[:acl]
|
1440
|
-
if token = config.credential_provider.session_token
|
1441
|
-
parts << "x-amz-security-token:#{token}"
|
1442
|
-
end
|
1443
|
-
parts << Core::Signers::S3.canonicalized_resource(request)
|
1444
|
-
|
1445
|
-
string_to_sign = parts.join("\n")
|
1446
|
-
|
1447
|
-
secret = config.credential_provider.secret_access_key
|
1448
|
-
Core::Signers::Base.sign(secret, string_to_sign, 'sha1')
|
1449
|
-
end
|
1450
|
-
|
1451
|
-
def expiration_timestamp(input)
|
1452
|
-
input = input.to_int if input.respond_to?(:to_int)
|
1453
|
-
case input
|
1454
|
-
when Time then input.to_i
|
1455
|
-
when DateTime then Time.parse(input.to_s).to_i
|
1456
|
-
when Integer then (Time.now + input).to_i
|
1457
|
-
when String then Time.parse(input).to_i
|
1458
|
-
else (Time.now + 60*60).to_i
|
1459
|
-
end
|
1460
|
-
end
|
1461
|
-
|
1462
|
-
def http_method(input)
|
1463
|
-
symbol = case input
|
1464
|
-
when :read then :get
|
1465
|
-
when :write then :put
|
1466
|
-
else
|
1467
|
-
input
|
1468
|
-
end
|
1469
|
-
symbol.to_s.upcase
|
1470
|
-
end
|
1471
|
-
|
1472
|
-
def request_for_signing(options)
|
1473
|
-
|
1474
|
-
port = [443, 80].include?(config.s3_port) ?
|
1475
|
-
(options[:secure] ? 443 : 80) :
|
1476
|
-
config.s3_port
|
1477
|
-
|
1478
|
-
req = Request.new
|
1479
|
-
|
1480
|
-
req.bucket = bucket.name
|
1481
|
-
req.key = key
|
1482
|
-
req.host = options.fetch(:endpoint, config.s3_endpoint)
|
1483
|
-
req.port = options.fetch(:port, port)
|
1484
|
-
req.force_path_style = options.fetch(:force_path_style, config.s3_force_path_style)
|
1485
|
-
|
1486
|
-
REQUEST_PARAMETERS.each do |param|
|
1487
|
-
req.add_param(param.to_s.tr("_","-"),
|
1488
|
-
options[param]) if options.key?(param)
|
1489
|
-
end
|
1490
|
-
|
1491
|
-
req
|
1492
|
-
end
|
1493
|
-
|
1494
|
-
def add_sse_options(options)
|
1495
|
-
unless options.key?(:server_side_encryption)
|
1496
|
-
options[:server_side_encryption] = config.s3_server_side_encryption
|
1497
|
-
end
|
1498
|
-
options.delete(:server_side_encryption) if
|
1499
|
-
options[:server_side_encryption].nil?
|
1500
|
-
end
|
1501
|
-
|
1502
|
-
# Adds client-side encryption metadata headers and encrypts key
|
1503
|
-
def add_cse_options(options)
|
1504
|
-
encryption_key_for(options) do |encryption_key|
|
1505
|
-
|
1506
|
-
check_encryption_materials(:encrypt, encryption_key)
|
1507
|
-
cipher = get_aes_cipher(:encrypt, :CBC)
|
1508
|
-
|
1509
|
-
generate_aes_key(cipher) do |envelope_key, envelope_iv|
|
1510
|
-
envelope_key, envelope_iv =
|
1511
|
-
encode_envelope_key(encryption_key, envelope_key, envelope_iv)
|
1512
|
-
|
1513
|
-
build_cse_metadata(options,
|
1514
|
-
envelope_key,
|
1515
|
-
envelope_iv) do |headers, encryption_materials|
|
1516
|
-
store_encryption_materials(options, headers, encryption_materials)
|
1517
|
-
end
|
1518
|
-
end
|
1519
|
-
|
1520
|
-
# Wrap current stream in encryption
|
1521
|
-
options[:data] = CipherIO.new(cipher,
|
1522
|
-
options[:data],
|
1523
|
-
options[:content_length])
|
1524
|
-
|
1525
|
-
# Update content_length
|
1526
|
-
options[:content_length] =
|
1527
|
-
get_encrypted_size(options[:content_length]) if
|
1528
|
-
options[:content_length]
|
1529
|
-
|
1530
|
-
end
|
1531
|
-
remove_cse_options(options)
|
1532
|
-
end
|
1533
|
-
|
1534
|
-
# @yield [String, String] Yields an encrypted encoded key and iv pair
|
1535
|
-
def encode_envelope_key encryption_key, envelope_key, envelope_iv, &block
|
1536
|
-
envelope_key = encrypt(envelope_key, encryption_key)
|
1537
|
-
[encode64(envelope_key), encode64(envelope_iv)]
|
1538
|
-
end
|
1539
|
-
|
1540
|
-
# @yield [Hash, Hash] Yields headers and encryption materials that are
|
1541
|
-
# to be stored in the metadata and/or instruction file
|
1542
|
-
def build_cse_metadata options, enc_envelope_key, enc_envelope_iv, &block
|
1543
|
-
# Ensure metadata exists
|
1544
|
-
options[:metadata] = {} unless options[:metadata]
|
1545
|
-
|
1546
|
-
matdesc = options[:encryption_matdesc] || config.s3_encryption_matdesc
|
1547
|
-
|
1548
|
-
encryption_materials = {'x-amz-key' => enc_envelope_key,
|
1549
|
-
'x-amz-iv' => enc_envelope_iv,
|
1550
|
-
'x-amz-matdesc' => matdesc}
|
1551
|
-
orig_headers = {}
|
1552
|
-
|
1553
|
-
# Save the unencrypted content length
|
1554
|
-
if options[:content_length]
|
1555
|
-
orig_headers['x-amz-unencrypted-content-length'] =
|
1556
|
-
options[:content_length]
|
1557
|
-
end
|
1558
|
-
|
1559
|
-
# Save the unencrypted content MD5
|
1560
|
-
if options[:content_md5]
|
1561
|
-
orig_headers['x-amz-unencrypted-content-md5'] =
|
1562
|
-
options[:content_md5]
|
1563
|
-
options.delete(:content_md5)
|
1564
|
-
end
|
1565
|
-
|
1566
|
-
options[:metadata].merge!(orig_headers)
|
1567
|
-
|
1568
|
-
yield([orig_headers, encryption_materials])
|
1569
|
-
end
|
1570
|
-
|
1571
|
-
# Stores the headers and encryption materials needed to decrypt the data
|
1572
|
-
# and to know unencrypted information about the object
|
1573
|
-
def store_encryption_materials options, orig_headers, encryption_materials
|
1574
|
-
# Get the storage location
|
1575
|
-
cse_location = options[:encryption_materials_location] ||
|
1576
|
-
config.s3_encryption_materials_location
|
1577
|
-
|
1578
|
-
# Encryption type specific metadata
|
1579
|
-
case cse_location
|
1580
|
-
when :metadata
|
1581
|
-
options[:metadata].merge!(encryption_materials)
|
1582
|
-
when :instruction_file
|
1583
|
-
json_string = JSON.generate(encryption_materials)
|
1584
|
-
inst_headers = {'x-amz-crypto-instr-file' => ""}.merge(orig_headers)
|
1585
|
-
bucket.objects["#{key}.instruction"].write(json_string,
|
1586
|
-
:metadata => inst_headers)
|
1587
|
-
else
|
1588
|
-
msg = "invalid :encryption_materials_location, expected "
|
1589
|
-
msg << ":metadata or :instruction_file, got: #{cse_location.inspect}"
|
1590
|
-
raise ArgumentError, msg
|
1591
|
-
end
|
1592
|
-
nil
|
1593
|
-
end
|
1594
|
-
|
1595
|
-
# Removes any extra headers client-side encryption uses.
|
1596
|
-
def remove_cse_options options
|
1597
|
-
options.delete(:encryption_key)
|
1598
|
-
options.delete(:encryption_materials_location)
|
1599
|
-
options.delete(:encryption_matdesc)
|
1600
|
-
end
|
1601
|
-
|
1602
|
-
# Yields a decryption cipher for the given client-side encryption key
|
1603
|
-
# or raises an error.
|
1604
|
-
def decryption_cipher options, &block
|
1605
|
-
encryption_key_for(options) do |encryption_key|
|
1606
|
-
|
1607
|
-
check_encryption_materials(:decrypt, encryption_key)
|
1608
|
-
|
1609
|
-
location = options[:encryption_materials_location] ||
|
1610
|
-
config.s3_encryption_materials_location
|
1611
|
-
|
1612
|
-
cipher =
|
1613
|
-
decryption_materials(location, options) do |envelope_key, envelope_iv|
|
1614
|
-
envelope_key, envelope_iv =
|
1615
|
-
decode_envelope_key(envelope_key, envelope_iv, encryption_key)
|
1616
|
-
get_aes_cipher(:decrypt, :CBC, envelope_key, envelope_iv)
|
1617
|
-
end
|
1618
|
-
|
1619
|
-
remove_cse_options(options)
|
1620
|
-
|
1621
|
-
yield(cipher)
|
1622
|
-
|
1623
|
-
end
|
1624
|
-
end
|
1625
|
-
|
1626
|
-
# Decodes the envelope key for decryption
|
1627
|
-
def decode_envelope_key envelope_key, envelope_iv, encryption_key
|
1628
|
-
decrypted_key =
|
1629
|
-
begin
|
1630
|
-
decrypt(decode64(envelope_key), encryption_key)
|
1631
|
-
rescue RuntimeError
|
1632
|
-
msg = "Master key used to decrypt data key is not correct."
|
1633
|
-
raise AWS::S3::Errors::IncorrectClientSideEncryptionKey, msg
|
1634
|
-
end
|
1635
|
-
|
1636
|
-
[decrypted_key, decode64(envelope_iv)]
|
1637
|
-
end
|
1638
|
-
|
1639
|
-
|
1640
|
-
# @yield [String, String, String] Yields encryption materials for
|
1641
|
-
# decryption
|
1642
|
-
def decryption_materials location, options = {}, &block
|
1643
|
-
|
1644
|
-
materials = case location
|
1645
|
-
when :metadata then get_metadata_materials(options)
|
1646
|
-
when :instruction_file then get_inst_file_materials
|
1647
|
-
else
|
1648
|
-
msg = "invalid :encryption_materials_location option, expected "
|
1649
|
-
msg << ":metadata or :instruction_file, got: #{location.inspect}"
|
1650
|
-
raise ArgumentError, msg
|
1651
|
-
end
|
1652
|
-
|
1653
|
-
envelope_key, envelope_iv = materials
|
1654
|
-
|
1655
|
-
unless envelope_key and envelope_iv
|
1656
|
-
raise 'no encryption materials found, unable to decrypt'
|
1657
|
-
end
|
1658
|
-
|
1659
|
-
yield(envelope_key, envelope_iv)
|
1660
|
-
|
1661
|
-
end
|
1662
|
-
|
1663
|
-
# @return [String, String, String] Returns the data key, envelope_iv, and the
|
1664
|
-
# material description for decryption from the metadata.
|
1665
|
-
def get_metadata_materials(options)
|
1666
|
-
opts = {}
|
1667
|
-
opts[:version_id] = options[:version_id] if options[:version_id]
|
1668
|
-
metadata(opts).to_h.values_at(*%w(x-amz-key x-amz-iv))
|
1669
|
-
end
|
1670
|
-
|
1671
|
-
# @return [String, String, String] Returns the data key, envelope_iv, and the
|
1672
|
-
# material description for decryption from the instruction file.
|
1673
|
-
def get_inst_file_materials
|
1674
|
-
obj = bucket.objects["#{key}.instruction"]
|
1675
|
-
JSON.parse(obj.read).values_at(*%w(x-amz-key x-amz-iv))
|
1676
|
-
end
|
1677
|
-
|
1678
|
-
# @yield [Hash] Yields the metadata to be saved for client-side encryption
|
1679
|
-
def copy_cse_materials source, options
|
1680
|
-
cse_materials = {}
|
1681
|
-
meta = source.metadata.to_h
|
1682
|
-
cse_materials['x-amz-key'] = meta['x-amz-key'] if meta['x-amz-key']
|
1683
|
-
cse_materials['x-amz-iv'] = meta['x-amz-iv'] if meta['x-amz-iv']
|
1684
|
-
cse_materials['x-amz-matdesc'] = meta['x-amz-matdesc'] if
|
1685
|
-
meta['x-amz-matdesc']
|
1686
|
-
cse_materials['x-amz-unencrypted-content-length'] =
|
1687
|
-
meta['x-amz-unencrypted-content-length'] if
|
1688
|
-
meta['x-amz-unencrypted-content-length']
|
1689
|
-
cse_materials['x-amz-unencrypted-content-md5'] =
|
1690
|
-
meta['x-amz-unencrypted-content-md5'] if
|
1691
|
-
meta['x-amz-unencrypted-content-md5']
|
1692
|
-
|
1693
|
-
if
|
1694
|
-
cse_materials['x-amz-key'] and
|
1695
|
-
cse_materials['x-amz-iv'] and
|
1696
|
-
cse_materials['x-amz-matdesc']
|
1697
|
-
then
|
1698
|
-
options[:metadata] = (options[:metadata] || {}).merge(cse_materials)
|
1699
|
-
else
|
1700
|
-
# Handling instruction file
|
1701
|
-
source_inst = "#{source.key}.instruction"
|
1702
|
-
dest_inst = "#{key}.instruction"
|
1703
|
-
self.bucket.objects[dest_inst].copy_from(
|
1704
|
-
source.bucket.objects[source_inst])
|
1705
|
-
end
|
1706
|
-
end
|
1707
|
-
|
1708
|
-
# Removes unwanted options that should not be passed to the client.
|
1709
|
-
def clean_up_options(options)
|
1710
|
-
options.delete(:estimated_content_length)
|
1711
|
-
options.delete(:single_request)
|
1712
|
-
options.delete(:multipart_threshold)
|
1713
|
-
end
|
1714
|
-
|
1715
|
-
# Performs a write using a multipart upload
|
1716
|
-
def write_with_multipart options
|
1717
|
-
part_size = compute_part_size(options)
|
1718
|
-
clean_up_options(options)
|
1719
|
-
options.delete(:content_length)
|
1720
|
-
|
1721
|
-
multipart_upload(options) do |upload|
|
1722
|
-
upload.add_part(options[:data].read(part_size)) until
|
1723
|
-
options[:data].eof?
|
1724
|
-
end
|
1725
|
-
end
|
1726
|
-
|
1727
|
-
# Performs a write using a single request
|
1728
|
-
def write_with_put_object options
|
1729
|
-
|
1730
|
-
# its possible we don't know the content length of the data
|
1731
|
-
# option, but the :estimated_content_length was sufficiently
|
1732
|
-
# small that we will read the entire stream into memory
|
1733
|
-
# so we can tell s3 the content length (this is required).
|
1734
|
-
unless options[:content_length]
|
1735
|
-
data = StringIO.new
|
1736
|
-
|
1737
|
-
while (chunk = options[:data].read(4 * 1024))
|
1738
|
-
data << chunk
|
1739
|
-
end
|
1740
|
-
|
1741
|
-
options[:content_length] = data.size
|
1742
|
-
data.rewind
|
1743
|
-
options[:data] = data
|
1744
|
-
end
|
1745
|
-
|
1746
|
-
clean_up_options(options)
|
1747
|
-
|
1748
|
-
options[:bucket_name] = bucket.name
|
1749
|
-
options[:key] = key
|
1750
|
-
|
1751
|
-
resp = client.put_object(options)
|
1752
|
-
|
1753
|
-
resp.data[:version_id] ?
|
1754
|
-
ObjectVersion.new(self, resp.data[:version_id]) : self
|
1755
|
-
end
|
1756
|
-
|
1757
|
-
def encryption_key_for options, &block
|
1758
|
-
if key = options[:encryption_key] || config.s3_encryption_key
|
1759
|
-
yield(key)
|
1760
|
-
end
|
1761
|
-
end
|
1762
|
-
|
1763
|
-
def add_storage_class_option options
|
1764
|
-
if options[:reduced_redundancy] == true
|
1765
|
-
options[:storage_class] = 'REDUCED_REDUNDANCY'
|
1766
|
-
end
|
1767
|
-
end
|
1768
|
-
|
1769
|
-
# @return [String] Encodes a `String` in base 64 regardless of version of
|
1770
|
-
# Ruby for http headers (removes newlines).
|
1771
|
-
def encode64 input
|
1772
|
-
Base64.encode64(input).split("\n") * ""
|
1773
|
-
end
|
1774
|
-
|
1775
|
-
# @return [String] Decodes a `String` in base 64.
|
1776
|
-
def decode64 input
|
1777
|
-
Base64.decode64(input)
|
1778
|
-
end
|
1779
|
-
end
|
1780
|
-
end
|
1781
|
-
end
|