简体   繁体   English

使用回形针/云文件将图像保存到Rackspace

[英]Saving images to Rackspace with paperclip/cloudfiles

I have my rails app filled with about 30000 products from various suppliers. 我的Rails应用程序充满了来自各种供应商的约30000种产品。 Currently each product image_url is being hosted by individual suppliers. 当前,每个产品的image_url由单个供应商托管。 How would I go about saving each image from the image_url to my rackspace account, and make sure that each image_url generated by rackspace is assigned to the correct product. 如何将每个图像从image_url保存到我的机架帐户,并确保将由机架空间生成的每个image_url分配给正确的产品。

You could put this in a Rake task if you already have all the files and know which objects they should be associated with. 如果您已经拥有所有文件并知道应该与哪些对象关联,则可以将其放入Rake任务中。

For each product, 对于每种产品,

  1. Upload the image 上传图片
  2. Change the image_url 更改image_url
  3. Validate the upload + the model name 验证上载+型号名称
  4. Save the model 保存模型

If you need to keep track of which are processed or not, you could either add a field in the model, or keep an array of processed Models until the task is complete. 如果需要跟踪是否处理了哪些问题,则可以在模型中添加一个字段,也可以保留一系列已处理的模型,直到任务完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM