5
S3에서 기존 또는 새로 생성 된 파일에 텍스트를 추가하는 방법. 내가 fog
을 사용하고 내가 한 번 S3에 업로드 코드Ruby - 안개를 사용하여 기존 s3 파일의 끝에 내용 추가
require 'fog'
file = "abc.csv"
bucket = 'my_bucket'
storage = Fog::Storage.new(:provider => 'AWS', :aws_access_key_id => 'XXXXXXXX', :aws_secret_access_key => 'YYYYYYYY')
dir = connection.directories.new(:key => bucket) # no harm, if this bucket already exists, if not create one
buffer = ["big_chunk1", "big_chunk2", "big_chunk3", "big_chunk4", "big_chunk5"]
# I need help after this line. No changes above.
buffer.each do |chunk|
# this will not work as it will not append text below the existing file or
# newly created one. I am not looking for solution suggesting, buffer.join('')
# and then write whole chunk at once. I have to write in chuck for some specific reason.
# Also I dont want to first read existing data and then take in to memory
# and then append and finally write back.
dir.files.create(:key => file, :body => chunk, :public => false)
end
감사합니다. @Frederick Cheung. 나는 많은 연구를 한 후에 같은 결론에 도달했다. 그런데 안개를 사용하여 s3 url에 서명하는 방법을 알고 있습니까? 안개 문서에서 정보를 쉽게 찾을 수 없습니다. – JVK