import shopify
from base64 import b64encode
#omitted the shopify key
shopify.ShopifyResource.set_site(shop_url)
path = "product.jpg"
new_product = shopify.Product()
new_product.title = "title"
new_product.body_html = "This is a test"
image = shopify.Image()
with open(path, "rb") as f:
filename = path.split("/")[-1:][0]
#encoded = b64encode(f.read()) (I tried this one as well)
encoded = f.read()
image.attach_image(encoded, filename=filename)
new_product.images = image
new_product.save()
介してローカル画像をアップロードする:両方の試験においてShopify APIは、私は両方の方法試験パイソン
encoded = b64encode(f.read())
encoded = f.read()
を、出力が同じであった。
ただし、イメージは作成されませんでした。
image
がimage(None)
、new_products.images
が返されていることに気付きました。image(None)
も返されます。
どのように2枚の絵はどうしたら? –