我使用Paperclip
上传文件,fog-google
用作存储空间。
从rails console
和API
上传文件时,一切正常。但是当我尝试在我的模型上测试上传功能时,我收到ArgumentError: is not a recognized provider
错误。
以下是测试片段
```红宝石
context "saving images" do
it "save image to google cloud storoge" do
user = FactoryGirl.create(:user)
user.image = File.new("spec/fixtures/some_image.jpg")
user.save!
expect(user.reload.image.exists?).to eq(true)
end
end
```
附加Google生成的JSON密码文件
{
"type": "service_account",
"project_id": "some-project",
"private_key_id": "---somekeys----",
"private_key": "-----BEGIN PRIVATE KEY-----\n----private key------\n-----END PRIVATE KEY-----\n",
"client_email": "new-service-account@some-project.iam.gserviceaccount.com",
"client_id": "---client-id----------",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url":
"https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url":
"https://www.googleapis.com/robot/v1/metadata/x509/new-service-account%40some-project.iam.gserviceaccount.com"
}
Fog配置文件附在下面:
google_project: some-project
google_client_email: new-service-account@some-project.iam.gserviceaccount.com
google_json_key_location: ~/Desktop/some-project-8c5573bf9f32.json