0

我将Jet.com与基于Java的应用程序集成在一起。我成功地上传了Merchant Sku批量上传文件,但在合作伙伴仪表板中出现错误“未找到文件”。Jet.Com批量上传错误

的Java API代码:

 try { 

      String url = fileURL.get("url").toString().trim(); 
      String gzipFile = filePath + ".gz"; 
      FileInputStream fis = new FileInputStream(file); 
     FileOutputStream fos = new FileOutputStream(gzipFile); 
     GZIPOutputStream gzipOS = new GZIPOutputStream(fos); 
     byte[] buffer = new byte[1024]; 
     int len; 
     while((len=fis.read(buffer)) != -1){ 
      gzipOS.write(buffer, 0, len); 
     } 
     //close resources 
     gzipOS.close(); 
     fos.close(); 
     fis.close(); 

      HttpPut request = new HttpPut(url); 
      request.addHeader("x-ms-blob-type", "blockblob"); 

      FileEntity entity = new FileEntity(new File(gzipFile)); 
      entity.setContentType(ContentType.APPLICATION_OCTET_STREAM.toString()); 
      entity.setContentEncoding("gzip"); 
      request.setEntity(entity); 

      HttpResponse res = httpClient.execute(request); 
      System.out.println(EntityUtils.toString(res.getEntity())); 
      return true; 
    } 

在查看在Jet.com合作伙伴门户网站上传的文件,它提供了错误 “找不到文件”。我猜这个问题可能与HttpPut文件上传代码有关,但我不确定。

enter image description here

+0

请不要dd请求紧急/尽快等你的问题,[阅读更多](http://meta.stackoverflow.com/q/326569)。谢谢。 – halfer

+0

jet.com发回的HTTP返回码是什么? –

+0

返回代码是200 OK,如果您检查文件上传到Jet.com服务器,但它发出文件未找到错误 – Jayesh

回答

0

{"SL-SBEC-32L":{"product_title":"Foldable Fabric Drawer Lagoon Blue","product_description":"Brighten up your home with a lagoon blue Foldable Fabric Drawer from Tidy Living. The bright blue drawer offers a convenient way to organize and sort small items like cords, keys, cooking utensils and more. The cube-style drawers are perfect for use with cube organizers, open shelving units and more. The fabric drawers feature an open top for easy access and versatility. A built-in fabric handle on the front makes the drawer easy to grip and easy to operate. Foldable Fabric Drawers from Tidy Living are a great addition to any home’s decor and can even be used as a seasonal update. The medium cube organizers measure 10.5” W x 10.5” D x 11” H and are the perfect size for most uses. Other colors of fabric drawers are also available including black, red, and brown.","brand":"Tidy Living","standard_product_codes":[{"standard_product_code":"849392007293","standard_product_code_type":"UPC"}],"mfr_part_number":"SL-SBEC-32L","jet_browse_node_id":13000263,"multipack_quantity":1,"main_image_url":"https:\/\/tidyliving.com\/pub\/media\/catalog\/product\/s\/l\/sl-sbec-32l_-_non-woven_fabric_foldable_fabric_drawer_-_blue_-_angle.jpg","alternate_images":[{"image_slot_id":1,"image_url":"https:\/\/tidyliving.com\/pub\/media\/catalog\/product\/s\/l\/sl-sbec-32l_-_non-woven_fabric_foldable_fabric_drawer_-_blue_-_sideways.jpg"},{"image_slot_id":2,"image_url":"https:\/\/tidyliving.com\/pub\/media\/catalog\/product\/s\/l\/sl-sbec-32l_-_non-woven_fabric_foldable_fabric_drawer_-_blue_-_front.jpg"}]}}

这是JSON文件,该文件必须在.json.gz格式。

  1. 请检查json.gz格式是否正确。
  2. 之后,将其上传到您从“获取网址请求
  3. ”中获得的网址,如果需要,增加到期时间(以秒为单位)。
  4. 检查json.gz是否包含正确的merchantsku json文件。 5.检查放入请求标头是否包含x-ms-blob-type :blockblob
0

我不知道它的API使用的是批量产品上传, 如果您正在使用

https://developer.jet.com/docs/testinput-1 

那么您的网址应该是这样的:

https://prodimupload.blob.core.windows.net/merchant-files/ea74847dd3804e18a004233c4880e27b?sv=2015-04-05&sr=b&sig=6k2GN53DFdWSjFm%2BCA9nrA1i4nfGNVwmrYEzT%2FzVDPI%3D&se=2017-05-30T08%3A40%3A39Z&sp=w 

这你会得到当你打电话给这个api:

/files/uploadToken