Answer the question
In order to leave comments, you need to log in
Amazon s3 and paperclip. overwriting s3_permissions.?
The point is this. My project has s3_permissions: :private set by default .
For some type of pictures, I need to set public access.
For example, if the image has the active status, then the access is public, if the status changes, then the access changes to private.
Attention question. How do I override this setting before sending the image to amazon? and how to update it when the picture is already on amazon?
Answer the question
In order to leave comments, you need to log in
Well, in general, it's done like this:
# gem 'aws-sdk-v1'
s3 = AWS::S3.new(access_key_id: 'xxxx', secret_access_key: 'yyyy') # инициализируем клиент с нашими ключами
bucket = s3.buckets['sharikov-development-uploads'] # подписываем корзинку
obj = bucket.objects['assets/avatars/attachments/000/000/001/original/Photo.jpg'] # берем нужную пикчу
obj.acl=(:public_read) # делаем ее публичной
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question