全部產品
Search
文件中心

:資料合規上鏈

更新時間:Jul 06, 2024

使用REST API將資料上鏈時,我們可以通過Alibaba Content Security Service服務的整合,對上鏈內容進行前置檢查,避免違規資料上鏈。

下面以 Node.js 為例介紹如何使用REST API在資料上鏈前進行內容合規檢查。

前置條件

  1. 您需要先在區塊鏈執行個體中安裝雲端服務整合, 並開通Alibaba Content Security Service整合功能。

  2. 下載雲端服務整合範例程式碼

  3. 本地安裝 Node.js v8 環境(>=8.17.0)。

使用方法

  1. 按照文檔部署鏈碼將樣本鏈碼 notary 部署到通道中。

  2. 參考文檔使用REST API, 修改樣本 invoke-with-content-check 中的 main.js。

  3. 進入目錄 invoke-with-content-check 安裝 node 依賴項 npm install

  4. 使用 node main.js 啟動樣本。

樣本輸出

Data 1581905807512 pushed to blockchain with transaction 284d0b2b89db5bc5489127de863d0bb9b9d0a5f05bae67762567a3aff113822a
Content Moderation check failed: Send transaction failed: CONTENT_CHECK returned error VERIFY_FAILED: Content Moderation Check failed, suggestion block. key: 1581905807512, value: <此處略去用於測試的低俗內容>
Content Moderation check failed: Send transaction failed: CONTENT_CHECK returned error VERIFY_FAILED: Content Moderation Check failed, suggestion block. key: 1581905807512, value: <此處略去用於測試的政治敏感內容>

進階

如果預設的Alibaba Content Security Service檢查策略不能滿足您的業務要求,您可以登入Alibaba Content Security Service控制台,參考文檔自訂文本庫來擴充檢查規則或對上鏈內容檢查的行為進行調整。