2012-08-03 34 views
7

我正在嘗試設置我的Rails應用程序,使用asset_sync寶石將其資產上傳到Amazon的AWS S3,繼these instructions之後。我知道我已經配置了我的S3配置,因爲我的應用可以將圖像上傳到S3。我敢肯定,我已經得到了所有的設置正確:爲什麼`rake assets:precompile` throwing「getaddrinfo:Name or service not known」? (re:asset_sync)

FOG_DIRECTORY => mybucketname 
FOG_PROVIDER => AWS 
FOG_REGION => s3-us-west-2 

然而,我不斷收到錯誤:

-bash> heroku run rake assets:precompile --remote staging 
Running rake assets:precompile attached to terminal... up, run.1 
AssetSync: using default configuration from built-in initializer 
mkdir -p /app/public/assets 
... 
mkdir -p /app/public/assets 
AssetSync: Syncing. 
rake aborted! 
getaddrinfo: Name or service not known        # <-- error 

本地編譯生成一個略有不同的錯誤:

-bash> bundle exec rake assets:precompile 
AssetSync: using default configuration from built-in initializer 
mkdir -p /Users/bart/Dev/MyApp/myapp/public/assets 
... 
mkdir -p /Users/bart/Dev/MyApp/myapp/public/assets 
AssetSync: Syncing. 
rake aborted! 
getaddrinfo: nodename nor servname provided, or not known    # <-- error 

回答

10

我將錯誤追溯到a 'connection' line in Fogasset_sync的運行時依賴項之一,事實證明我的FOG_REGION設置不正確。在我的情況下,該地區應該是us-west-2,而不是s3-us-west-2

自從我配置了我的S3帳戶以來,我一直在嘗試通過登錄AWS S3控制檯,單擊存儲桶名稱,然後單擊「屬性」來確定我使用的區域。在那裏,該地區被列爲俄勒岡州。那麼,這沒有用。然後,我點擊了我現有桶的對象和文件夾瀏覽器,直到找到資產,查找其「屬性」,然後看到「鏈接」:

https:// s3-us-西2 .amazonaws.com/mybucketname /上傳/爲MyModel /圖像/ 1135/myimage.jpg

我確信s3-us-west-2是正確的,直到我注意到Fog adds the s3- prefix

反正我現在知道,一旦你的名字(例如俄勒岡州)找出你的區域,你可以看看它在this list of S3 regions(它的列位置約束下的名稱)。

我希望這可以幫助別人。

+0

很好的答案。仍然不明白爲什麼亞馬遜這樣一家大公司的用戶界面非常差 – 2013-11-14 08:54:41

相關問題