Background:Developers/sellers may meet some errors when trying to upload/edit products using external url. For example: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target...
Further more, conditions of sellers' servers might vary in different countries, thus causing unstability when using external url. Currently,it is recommend to use the images' photobank_url to post or edit the products.
Solution:Recommended process is the following flow chart.
Relative API:aliexpress.photobank.redefining.uploadimageforsdk
While invoking the API,the object FileItem for parameter "imagebytes" are important:
1.When the image you want to upload to the photobank is a local one,you can just use its local filepath:
TaobaoClient client = new DefaultTaobaoClient(url, appkey, appsecret); AliexpressPhotobankRedefiningUploadimageforsdkRequest req = new AliexpressPhotobankRedefiningUploadimageforsdkRequest(); //req.setGroupId("0"); req.setImageBytes(new FileItem("/Users/zy/Desktop/zhaoyao/test.jpg")); req.setFileName("test.jpg"); AliexpressPhotobankRedefiningUploadimageforsdkResponse rsp = client.execute(req, sessionKey); System.out.println(rsp.getBody());
2.When you trying to upload external images, it needs to be transformed into byte[] for processing.(One point to be noticed is that the external image URL could be access successfully). The following code is an example.
Uploaded successfully:
After you upload the images to photobank successfully,the photobank_url will be returned in response(within "alicdn.com"), for example:"https://ae01.alicdn.com/kf/Hf34573381bfc48e98a86f718261f5049z.jpg".The developers now needs to store the mapping between the origin url and the photobank_url and using the photobank_url to post/edit products subsequently.