我将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文件上传代码有关,但我不确定。
请不要dd请求紧急/尽快等你的问题,[阅读更多](http://meta.stackoverflow.com/q/326569)。谢谢。 – halfer
jet.com发回的HTTP返回码是什么? –
返回代码是200 OK,如果您检查文件上传到Jet.com服务器,但它发出文件未找到错误 – Jayesh