How do I replace an existing Community file on IBM SmartCloud

105 views Asked by At

I am trying to replace an existing Community file using the following java

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

But it is returning a HTTP 411:Length required error.

I am using the latest build (1.1.5.20150520-1200.jar)

Does anyone have a suggestion as to what i am missing?

1

There are 1 answers

5
Vimal Dhupar On

I tried recreating the issue but I am able to upload New version of Community file correctly with and without version, using the updateCommunityFile API. I do not get any Length related error. This is the snippet I am using :

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);

Can you share more details on your sample, what exactly is your fis? I have tried this on 2 environments and I do not see any issue.

Also, from the entry you have pasted,

"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" 

It seems that somehow an incorrect content-length is passed for your request. Can you share the sample that you are using?