如何让用户能够将其内容上传到我的RoR应用程序,然后再访问以下静态内容:
答案 0 :(得分:1)
您可以重定向到静态内容,例如
class ImagesController
def show
@image = Image.find(params[:id])
if user_has_access_to @image
redirect_to @image.bizarre_and_secret_image_location_that_is_served_by_apache
else
access_denied
end
end
end
它确实无法完全保护内容。也许暂时使静态URL有用:
RewriteRule ^/images/RANDOMIZED_PREFIX_HERE/(.+)$ images/SECRET_IMAGE_LOCATION/$1 [L]
...现在每小时更改一次.htaccess
文件。当然,应用程序也应该知道前缀。