I am uploading the file using the IBM Social Business Toolkit and now want to add tag(s) to it. Either as part of the upload or immediately afterwards. In the javadocs I can see that the FileService has a method to add a comment to a file. I can't see an equivalent for Tags though.
Asked
Active
Viewed 84 times
1 Answers
1
There is a Java method to update a tag on a community file - but it is broken in the most recent version of Smartcloud. It has actually been fixed in the most recent GitHub version of the code but it is not available for download as of April 2015.
The bug is reported here https://github.com/OpenNTF/SocialSDK/issues/1624. The method SHOULD be updateCommunityFileMetadata and with that we could add TAGs as Metadata. That would be simple to add to the end of the "addFile" Java method.
The sample code to TAG a file can be found here in the playgroup - it is updating the Meta Data via JavaScript API
to TAG a file use the following
function tagFile(yourFileId, yourDocUnid){
require([ "sbt/connections/FileService", "sbt/dom", "sbt/json" ], function(FileService, dom, json) {
var fileService = new FileService();
var fileId = yourFileId
var docId = yourDocUnid
var tagArray = [];
tagArray.push(docId)
fileService.updateCommunityFileMetadata({
id: fileId,
tags: tagArray
}, communityId).then(function(file) {
dom.setText("json", json.jsonBeanStringify(file));
}, function(error) {
dom.setText("json", json.jsonBeanStringify(error));
});
});
}

MarkyRoden
- 1,074
- 6
- 21
-
please use the releases tab to download the latest build - https://github.com/OpenNTF/SocialSDK/releases – Paul Bastide Apr 20 '15 at 17:50
-
Paul, I downloaded the latest build (v1.1.3.20150220) and was able to add a tag using fileService.uploadCommunityFile. However it also added a second tag "tag_word" of its own volition. Where does that come from? Also, I couldn't figure out how to add two separate tags. If I put a second entry in the params hashmap it only adds the second tag, ignoring the first one. And still adds its own "tag_word" tag. – Martin Perrie Apr 21 '15 at 09:41
-
I think you should get the build from releases link above. We fixed that issue somewhat recently. – Paul Bastide Jul 23 '15 at 12:51
-
I have downloaded v1.1.5.20150520-1200 but am still seeing "tag_word" as additional tag in SmartCloud. Also, when listing tags using fileEntry.getTags(); I see another additional tag ("document") although this is not shown when viewing in SmartCloud. – Martin Perrie Jul 27 '15 at 09:49