2011-06-10 46 views

回答

4

您應該將資產保留在像S3/Cloudfront這樣的CDN上。然後根據需要重定向請求。

我也會用回形針來管理文件。它可能看起來像...

class AssetController < ApplicationController 

    def show 
    @asset = Asset.find(params[:id]) 
    redirect_to URI.encode @asset.file.url 
    end 

end 

class Asset 

    has_attached_file :file, 
     :path => YOUR_PATH, 
     :storage => :s3, 
     :s3_credentials => S3_CONFIG, 
     :bucket => BUCKET_NAME 

end 

這應該讓你開始。希望這可以幫助