2016-03-04 34 views
0
unless skip_error_checks 
    bucket_source = @@s3.bucket(from_bucket) 
    bucket_dest = @@s3.bucket(to_bucket) 
    old_object = bucket_source.objects(name) 
    new_object = bucket_dest.objects(new_name) 
    new_exists = new_object.exists? 
    old_exists = old_object.exists? 
    if new_exists && old_exists 
    return error("#{name} in #{from_bucket} and #{new_name} in #{to_bucket} exist.") 
    elsif new_exists && !old_exists 
    return error("This action has been done already.") 
    elsif !old_exists 
    return error("#{name} in #{from_bucket} do not exist it may have been permanently deleted.") 
    end 

我使用AWS-SDK 2.1.4即使我跟随AWS-SDK的文档看到nomethod错误,没有任何人有同样的问题NoMethodError:未定义的方法'存在吗?'为#<AWS ::资源::收藏:0x00000100b690f8>

回答

1

exists?方法从版本2开始已经removed

某些方法have been added to only some classes。如果要添加其他exists?的解决方案是通过提供的链接给出:

To add additional #exists? methods, a waiter must be added to the resource class as Exists and that waiter must be defined in the *.waiters.json document for that service.

+0

但在AWS-SDK版本2的文件有选择http://docs.aws.amazon.com/sdkforruby/api/ Aws/S3/Object.html – s7p7

+0

正如我在答案中所说的,它只针对某些类实现,但您可以添加自己的类。 – Mhmd

相关问题