如何在远程服务器(通过 pem 文件访问)rails 控制台上传回形针图像?

How can I upload paperclip image on remote server (accessed by pem file) rails console?

我有生产服务器,数据库来自 aws。我使用 pem 文件访问远程机器并启动 rails console.

我有特定的受邀者(来自 Invitee 模型)并且有以下列使用 paperclip

存储图像

invitee.rb

  has_attached_file :profile_pic, {:styles => {:large => "640x640>",
                                         :small => "200x200>", 
                                         :thumb => "60x60>"},
                                   :convert_options => {:large => "-strip -quality 90", 
                                         :small => "-strip -quality 80", 
                                         :thumb => "-strip -quality 80"}
                                         }.merge(INVITEE_IMAGE_PATH)

我想使用 rails console productionhttps://imgur.com/9a6UzVx 上传图片。我该怎么做?

我可以输入的是图像 url 和要更新 profile_pic 列的被邀请者的对象。

我的本地机器上有图像,但我无法将它从本地上传到远程,所以使用 https://imglur.com

我建议你检查另一个答案 “用回形针保存来自 URL 的图像 “ 实现了您想要实现的目标。检查 code snippet: self.profile_pic = open(url) will upload the picture to your model. Your picture real URL is https://i.imgur.com/9a6UzVx.png