0
我尝试使用Ruby在magento API上上传图像。如何使用Ruby在Magento Api上创建产品图像
这是我的代码:
require 'rubygems'
require 'soap/wsdlDriver'
require 'base64'
WSDL_URL = 'http://teeshop.chandru/api/v2_soap/?wsdl=1'
soap = SOAP::WSDLDriverFactory.new(WSDL_URL).create_rpc_driver
session = soap.login('*********','*********')
a = File.read('image/CP0760-01.jpg')
enc = Base64.encode64(a)
create_image = { 'file' => {"name" => "CP0760-01.jpg", "content" => enc,"mime" => 'image/jpeg'}, "label" => "kids cloths","position" => 0, "types" => ["image,""small_image", "thumbnail" ], "exclude" => 0 }
product_image = soap.call('catalogProductAttributeMediaCreate',session,'CP0760 (P.34)',creeate_image,1,'sku')
当我运行这段代码,我得到这个错误:
The image contents is not valid base64 data. (SOAP::FaultError)
是否有我的问题的任何解决方案?
感谢