如何以编程方式将标记添加到IBM SmartCloud上传到社区的文件?

时间:2015-04-20 15:00:43

标签: ibm-sbt

我使用IBM Social Business Toolkit上传文件,现在想要添加标签。作为上传的一部分或紧接其后。在javadocs中,我可以看到FileService有一个向文件添加注释的方法。虽然我看不到标签的等价物。

1 个答案:

答案 0 :(得分:1)

有一种Java方法可以更新社区文件上的标记 - 但是在最新版本的Smartcloud中它已被破坏。它实际上已在最新的GitHub版本的代码中修复,但截至2015年4月无法下载。

此处报告错误https://github.com/OpenNTF/SocialSDK/issues/1624。该方法应该是updateCommunityFileMetadata,我们可以将TAG添加为元数据。这将很容易添加到" addFile" Java方法。

TAG文件的示例代码可以在playgroup中找到 - 它正在通过JavaScript API更新元数据

https://greenhouse.lotus.com/sbt/sbtplayground.nsf/JavaScriptSnippets.xsp#snippet=Social_Files_API_UpdateCommunityFileMetadata

要标记文件,请使用以下

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

    });
}
相关问题