How to make 10,000 files in S3 public

前端 未结 9 963
梦如初夏
梦如初夏 2020-12-04 07:07

I have a folder in a bucket with 10,000 files. There seems to be no way to upload them and make them public straight away. So I uploaded them all, they\'re private, and I ne

9条回答
  •  伪装坚强ぢ
    2020-12-04 07:28

    I had the same problem, solution by @DanielVonFange is outdated, as new version of SDK is out.

    Adding code snippet that works for me right now with AWS Ruby SDK:

    require 'aws-sdk'
    
    Aws.config.update({
      region: 'REGION_CODE_HERE',
      credentials: Aws::Credentials.new(
        'ACCESS_KEY_ID_HERE',
        'SECRET_ACCESS_KEY_HERE'
      )
    })
    bucket_name = 'BUCKET_NAME_HERE'
    
    s3 = Aws::S3::Resource.new
    s3.bucket(bucket_name).objects.each do |object|
      puts object.key
      object.acl.put({ acl: 'public-read' })
    end
    

提交回复
热议问题