2016-11-12 3 views
0

Я пытаюсь зарегистрироваться через Facebook, чтобы создать пользователя с аватаром с помощью paperclip и использовать Amazon S3 на моем сайте, чтобы сохранить пользовательские аватары. Я ожидаю, что пользователи смогут добавлять аватар в свои профили, но кажется, что мне отказали в доступе. Я посмотрел и попробовал несколько решений без успеха.Сохранение аватара пользователя на paperclip и Aws :: S3 :: Ошибки :: AccessDenied

Вот ошибки в моем браузере:

Aws::S3::Errors::AccessDenied in SessionsController#create 
Access Denied 

Извлеченные источника (около линии № 19):

17 
18 
19 def self.create_user_from_facebook(auth) 
     create(
     avatar: process_uri(auth['info']['image'] + "?width=9999"), 
     email: auth['info']['email'], 
     provider: auth['provider'], 

in the commnad-line errors: 
SQL (0.6ms) INSERT INTO "users" ("provider", "uid", "name", "email", "created_at", "updated_at", "avatar_file_name", "avatar_content_type", "avatar_file_size", "avatar_updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["provider", "facebook"], ["uid", "10209320526747935"], ["name", "Ziv Steeven Zamechek"], ["email", "[email protected]"], ["created_at", 2016-11-12 18:15:38 UTC], ["updated_at", 2016-11-12 18:15:38 UTC], ["avatar_file_name", "picture"], ["avatar_content_type", "image/jpeg"], ["avatar_file_size", 15297], ["avatar_updated_at", 2016-11-12 18:15:38 UTC]] 
[paperclip] saving /users/avatars/000/000/001/original/picture 
    (0.3ms) rollback transaction 
Completed 500 Internal Server Error in 409ms (ActiveRecord: 1.8ms) 



Aws::S3::Errors::AccessDenied (Access Denied): 

app/models/user.rb:19:in `create_user_from_facebook' 
app/models/user.rb:15:in `sign_in_from_facebook' 
app/controllers/sessions_controller.rb:6:in `create' 

вот user.rb:

class User < ActiveRecord::Base 

    has_many :friendships, dependent: :destroy 
    has_many :inverse_friendships, class_name: "Friendship", foreign_key: "friend_id", dependent: :destroy 

    has_attached_file :avatar, 
         :storage => :s3, 
         :style => { :medium => "370x370", :thumb => "100x100" } 

    validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/ 

    default_scope { order('id DESC') } 

    def self.sign_in_from_facebook(auth) 
     find_by(provider: auth['provider'], uid: auth['uid']) || create_user_from_facebook(auth) 
    end 

    def self.create_user_from_facebook(auth) 
     create(
     avatar: process_uri(auth['info']['image'] + "?width=9999"), 
     email: auth['info']['email'], 
     provider: auth['provider'], 
     uid: auth['uid'], 
     name: auth['info']['name'], 
     gender: auth['extra']['raw_info']['gender'], 
     date_of_birth: auth['extra']['raw_info']['birthday'], 
     location: auth['info']['location'], 
     bio: auth['extra']['raw_info']['bio'] 
     ) 
    end 
end 

Мои github repo: https://github.com/zivolution921/tinstuk

ответ

0

Звучит как проблема разрешения на вашем ведре S3 и не имеет никакого отношения к вашему коду.