내가 AWS에 저장된 파일 이름을 업데이트하기 위해 노력하고있어 코드 아래 사용 S3'aws-sdk'를 사용하여 저장 한 후 S3 버킷의 파일 이름을 바꾸는 방법은 무엇입니까?
gem 'aws-sdk', '~> 2.3'
creds = Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY'])
s3 = Aws::S3::Resource.new(credentials: creds, region: ENV['AWS_REGION'])
bucket = s3.bucket(ENV['AWS_S3_BUCKET'])
filename = URI.unescape(document.url).split('/').last
new_file = 'new_file_name'
obj = bucket.object(filename) # create object of original file name
obj.move_to("#{bucket.name}/#{new_file}", acl: 'public-read')
obj = bucket.object(new_file)
라인 obj.move_to("#{bucket.name}/#{new_file}", acl: 'public-read')
에 오류를주는 업데이트 :
Aws::S3::Errors::NoSuchKey
The specified key does not exist.
어떤 제안이나 방법 파일의 이름을 변경하는 아이디어 s3에?
감사
출력 내용은 다음과 같습니다 (잘못 된 줄 앞에 표시)? :'puts obj.inspect' – jeffdill2
obj.inspect 출력 : "# " –
Anna88
이 이름은 어디에서 얻습니까? '? 1513753985'는 객체 문자열의 일부가 아닌 쿼리 문자열처럼 보입니다. –