如何替换IBM SmartCloud上的现有社区文件

时间:2015-07-02 12:44:23

标签: ibm-sbt

我正在尝试使用以下java替换现有的社区文件

Map<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("createVersion", "false");
fileEntry = fileService.updateCommunityFile(fis, fileUuid, fileName, communityLibraryId, paramsMap);

但它返回HTTP 411:长度要求错误。

我正在使用最新版本(1.1.5.20150520-1200.jar)

有没有人建议我缺少什么?

1 个答案:

答案 0 :(得分:1)

我尝试重新创建此问题,但我可以使用updateCommunityFile API正确上传包含和不使用版本的社区文件的新版本。我没有得到任何与长度相关的错误。这是我正在使用的片段:

java.io.File file = new java.io.File("C://TestUploadCommunity.txt");
FileInputStream fis = null;
try { 
    fis = new FileInputStream(file);
} catch (Exception e) {
    //TODO
}
fileEntry = fileService.updateCommunityFile(fis, fileEntry.getFileId(), fileEntry.getLabel(), communityLibraryId, params);

您能否分享有关样本的更多详细信息,您的fis究竟是什么? 我在2个环境中试过这个,但我没有看到任何问题。

此外,从您粘贴的条目

"Request to url apps.na.collabserv.com/files/basic/api/library... /document/... /entry?content-length=6600&createVersion=false returned an error response 411:Length Required HTTP/1.1 411" 

似乎某种方式为您的请求传递了不正确的内容长度。 你能分享你正在使用的样品吗?