AWS SDK-joya.S3Object#copy_to
Copies data from the current object to another object in S3.
S3 handles the copy so the client does not need to fetch the
data and upload it again. You can also change the storage
class and metadata of the object when copying.
Se utiliza copy_objectinternal método, por lo que la funcionalidad de copia le permite copiar objetos dentro o entre sus cubos S3, y opcionalmente para reemplazar los metadatos asociados con el objeto en el proceso.
método estándar (carga/descarga)
método Copy
Ejemplo de código:
require 'aws-sdk'
AWS.config(
:access_key_id => '***',
:secret_access_key => '***',
:max_retries => 10
)
file = 'test_file.rb'
bucket_0 = {:name => 'bucket_from', :endpoint => 's3-eu-west-1.amazonaws.com'}
bucket_1 = {:name => 'bucket_to', :endpoint => 's3.amazonaws.com'}
s3_interface_from = AWS::S3.new(:s3_endpoint => bucket_0[:endpoint])
bucket_from = s3_interface_from.buckets[bucket_0[:name]]
bucket_from.objects[file].write(open(file))
s3_interface_to = AWS::S3.new(:s3_endpoint => bucket_1[:endpoint])
bucket_to = s3_interface_to.buckets[bucket_1[:name]]
bucket_to.objects[file].copy_from(file, {:bucket => bucket_from})
me gustaría usar el fragmento de AWS-S3 pero estoy teniendo problemas al inicializar la clase AmazoneS3Asset. ¿Simplemente pongo el fragmento que define la clase en config/initializers? – deb
Encontré la respuesta a mi comentario aquí http://stackoverflow.com/questions/1146946/ruby-on-rails-and-external-classes – deb
aparentemente right_aws tiene esta importancia, no tuve que agregar el fragmento. Publiqué más información en la respuesta a continuación – deb