0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

鴻蒙開發(fā)文件管理:【@ohos.securityLabel (數(shù)據(jù)標(biāo)簽)】

jf_46214456 ? 來源:jf_46214456 ? 作者:jf_46214456 ? 2024-06-13 17:04 ? 次閱讀

數(shù)據(jù)標(biāo)簽

該模塊提供文件數(shù)據(jù)安全等級的相關(guān)功能:向應(yīng)用程序提供查詢、設(shè)置文件數(shù)據(jù)安全等級的JS接口。

icon-note.gif說明: 本模塊首批接口從API version 9開始支持。后續(xù)版本的新增接口,采用上角標(biāo)單獨標(biāo)記接口的起始版本。 開發(fā)前請熟悉鴻蒙開發(fā)指導(dǎo)文檔 :[gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md]

導(dǎo)入模塊

import securityLabel from '@ohos.securityLabel';

使用說明

使用該功能模塊對文件/目錄進行操作前,需要先獲取其應(yīng)用沙箱路徑,獲取方式及其接口用法請參考:

import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
let path = '';
context.getFilesDir().then((data) = > {
    path = data;
})

securityLabel.setSecurityLabel

setSecurityLabel(path:string, type:dataLevel):Promise

以異步方法設(shè)置數(shù)據(jù)標(biāo)簽,以promise形式返回結(jié)果。

系統(tǒng)能力 :SystemCapability.FileManagement.File.FileIO

參數(shù)

參數(shù)名類型必填說明
pathstring文件路徑
typedataLevel文件等級屬性,只支持"s0","s1","s2","s3","s4"

返回值:

類型說明
PromisePromise實例,用于異步獲取結(jié)果。本調(diào)用將返回空值。

示例:

let type = "s4";
securityLabel.setSecurityLabel(path, type).then(function(){
    console.info("setSecurityLabel successfully");
}).catch(function(error){
    console.info("setSecurityLabel failed with error:" + error);
});

securityLabel.setSecurityLabel

setSecurityLabel(path:string, type:dataLevel, callback: AsyncCallback):void

以異步方法設(shè)置數(shù)據(jù)標(biāo)簽,以callback形式返回結(jié)果。

系統(tǒng)能力 :SystemCapability.FileManagement.File.FileIO

參數(shù):

參數(shù)名類型必填說明
pathstring文件路徑
typedataLevel文件等級屬性,只支持"s0","s1","s2","s3","s4"
callbackAsyncCallback是否設(shè)置數(shù)據(jù)標(biāo)簽之后的回調(diào)

示例:

let type = "s4";
securityLabel.setSecurityLabel(path, type, function(error){
    console.info("setSecurityLabel:" + JSON.stringify(error));
});

securityLabel.setSecurityLabelSync

setSecurityLabelSync(path:string, type:dataLevel):void

以同步方法設(shè)置數(shù)據(jù)標(biāo)簽。

系統(tǒng)能力 :SystemCapability.FileManagement.File.FileIO

參數(shù):

參數(shù)名類型必填說明
pathstring文件路徑
typedataLevel文件等級屬性,只支持"s0","s1","s2","s3","s4"

示例:

let type = "s4";
securityLabel.setSecurityLabelSync(path, type);

securityLabel.getSecurityLabel

getSecurityLabel(path:string):Promise

異步方法獲取數(shù)據(jù)標(biāo)簽,以promise形式返回結(jié)果。

系統(tǒng)能力 :SystemCapability.FileManagement.File.FileIO

參數(shù):

參數(shù)名類型必填說明
pathstring文件路徑

返回值:

類型說明
Promise返回數(shù)據(jù)標(biāo)簽

示例:

let type = "s4";
securityLabel.getSecurityLabel(path).then(function(type){
    console.log("getSecurityLabel successfully:" + type);
}).catch(function(error){
    console.log("getSecurityLabel failed with error:" + error);
});

securityLabel.getSecurityLabel

getSecurityLabel(path:string, callback:AsyncCallback): void

異步方法獲取數(shù)據(jù)標(biāo)簽,以callback形式返回結(jié)果。

系統(tǒng)能力 :SystemCapability.FileManagement.File.FileIO

參數(shù):

參數(shù)名類型必填說明
pathstring文件路徑
callbackAsyncCallback異步獲取數(shù)據(jù)標(biāo)簽之后的回調(diào)

示例:

let type = "s4";
securityLabel.getSecurityLabel(path,function(error, type){
    console.log("getSecurityLabel successfully:" + type);
});

securityLabel.getSecurityLabelSync

getSecurityLabelSync(path:string):string

以同步方法獲取數(shù)據(jù)標(biāo)簽。

系統(tǒng)能力 :SystemCapability.FileManagement.File.FileIO

參數(shù):

參數(shù)名類型必填說明
pathstring文件路徑

返回值:

類型說明
string返回數(shù)據(jù)標(biāo)簽HarmonyOSOpenHarmony鴻蒙文檔籽料:mau123789是v直接拿

搜狗高速瀏覽器截圖20240326151450.png

示例:

let result = securityLabel.getSecurityLabelSync(path);
console.log("getSecurityLabel successfully:" + result);

審核編輯 黃宇

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • 接口
    +關(guān)注

    關(guān)注

    33

    文章

    8355

    瀏覽量

    150517
  • 鴻蒙
    +關(guān)注

    關(guān)注

    57

    文章

    2287

    瀏覽量

    42629
收藏 人收藏

    評論

    相關(guān)推薦

    鴻蒙原生應(yīng)用開發(fā)-網(wǎng)絡(luò)管理模塊總述

    進行數(shù)據(jù)傳輸。 二、約束與限制 使用網(wǎng)絡(luò)管理模塊的相關(guān)功能時,需要請求相應(yīng)的權(quán)限。 三、具體權(quán)限名與說明 ohos.permission.GET_NETWORK_INFO獲取網(wǎng)絡(luò)連接信息
    發(fā)表于 04-08 09:45

    labview實時標(biāo)簽打印條碼打印

    在labview下使用標(biāo)簽打印有兩種方法,我總結(jié)了一下?;救缦拢?.使用zpl語言 可以根據(jù)標(biāo)簽個格式和內(nèi)容,編輯zpl命令集合,輸出到打印端口2使用標(biāo)簽編輯軟件,調(diào)用軟件中的控件或者動態(tài)庫。這個需要拿到
    發(fā)表于 11-28 20:06

    esp8266那個模塊能發(fā)文件嗎?

    esp8266那個模塊能發(fā)文件嗎怎么發(fā)高手指點一下
    發(fā)表于 07-03 03:34

    esp8266收發(fā)文件中的接收固件該怎么處理呢?

    我想用esp8266 來做stm32的固件升級 那這樣的話就需要接收esp8266就需要接收發(fā)過來的固件(文件),這個接收固件(bin文件)怎么做處理呢? 求高手指教,之前也提問過一個收發(fā)文件的問題 ,感覺還不是太清楚
    發(fā)表于 07-31 00:29

    鴻蒙設(shè)備學(xué)習(xí)菜鳥指南》之 【五、搭建開發(fā)環(huán)境】

    全套開發(fā)環(huán)境? Linux系統(tǒng):同上 開發(fā)環(huán)境建立后,我們要做的第一件事情,就是在建立一個目錄,名字叫做OHOS,后面我們的開發(fā)文件,都放在這個目錄內(nèi),便于統(tǒng)一
    發(fā)表于 10-30 13:59

    在網(wǎng)頁遠程前面板中,觸發(fā)文件對話框子VI沒有反應(yīng) 要怎么解決

    想實現(xiàn)通過網(wǎng)頁遠程前面板,上傳文件到程序中這個功能,但是在網(wǎng)頁中點擊按鈕觸發(fā)文件對話框按鈕沒有反應(yīng)
    發(fā)表于 05-30 15:57

    嵌入式linux系統(tǒng)開發(fā)文件類型

    、符號鏈接文件、管道文件、套接字文件、字符設(shè)備文件、塊設(shè)備文件。下面尚觀教育小編給同學(xué)們講解嵌入式linux
    發(fā)表于 08-27 11:31 ?388次閱讀

    鴻蒙開發(fā)實戰(zhàn):【文件管理

    文件管理相關(guān)的功能,使用[@ohos.multimedia.medialibrary]、[@ohos.filemanagement.userFileManager]?、[@
    的頭像 發(fā)表于 03-20 21:57 ?569次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發(fā)</b>實戰(zhàn):【<b class='flag-5'>文件</b><b class='flag-5'>管理</b>】

    鴻蒙開發(fā)文件管理:【@ohos.document (文件交互)】

    通過文件管理器選擇文件,異步返回文件URI,使用promise形式返回結(jié)果。
    的頭像 發(fā)表于 06-11 17:51 ?369次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發(fā)文件</b><b class='flag-5'>管理</b>:【@<b class='flag-5'>ohos</b>.document (<b class='flag-5'>文件</b>交互)】

    鴻蒙開發(fā)文件管理:【@ohos.environment (目錄環(huán)境能力)】

    該模塊提供環(huán)境目錄能力,獲取內(nèi)存存儲根目錄、公共文件根目錄的JS接口。
    的頭像 發(fā)表于 06-13 10:27 ?377次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發(fā)文件</b><b class='flag-5'>管理</b>:【@<b class='flag-5'>ohos</b>.environment (目錄環(huán)境能力)】

    鴻蒙開發(fā)文件管理:【@ohos.fileio (文件管理)】

    該模塊提供文件存儲管理能力,包括文件基本管理、文件目錄管理、
    的頭像 發(fā)表于 06-12 18:12 ?994次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發(fā)文件</b><b class='flag-5'>管理</b>:【@<b class='flag-5'>ohos</b>.fileio (<b class='flag-5'>文件</b><b class='flag-5'>管理</b>)】

    鴻蒙開發(fā)文件管理:【@ohos.fileManager (公共文件訪問與管理)】

    該模塊提供公共文件訪問和管理的服務(wù)接口,向下對接底層文件管理服務(wù),如媒體庫、外卡管理;向上對應(yīng)用程序提供公共
    的頭像 發(fā)表于 06-12 17:00 ?657次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發(fā)文件</b><b class='flag-5'>管理</b>:【@<b class='flag-5'>ohos</b>.fileManager (公共<b class='flag-5'>文件</b>訪問與<b class='flag-5'>管理</b>)】

    鴻蒙開發(fā)文件管理:【@ohos.statfs (statfs)】

    該模塊提供文件系統(tǒng)相關(guān)存儲信息的功能,向應(yīng)用程序提供獲取文件系統(tǒng)總字節(jié)數(shù)、空閑字節(jié)數(shù)的JS接口。
    的頭像 發(fā)表于 06-13 09:46 ?226次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發(fā)文件</b><b class='flag-5'>管理</b>:【@<b class='flag-5'>ohos</b>.statfs (statfs)】

    鴻蒙開發(fā)文件管理:【@ohos.storageStatistics (應(yīng)用空間統(tǒng)計)】

    該模塊提供空間查詢相關(guān)的常用功能:包括對內(nèi)外卡的空間查詢,對應(yīng)用分類數(shù)據(jù)統(tǒng)計的查詢,對應(yīng)用數(shù)據(jù)的查詢等。
    的頭像 發(fā)表于 06-13 17:23 ?381次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發(fā)文件</b><b class='flag-5'>管理</b>:【@<b class='flag-5'>ohos</b>.storageStatistics (應(yīng)用空間統(tǒng)計)】

    鴻蒙開發(fā)文件管理:【@ohos.volumeManager (卷管理)】

    該模塊提供卷、磁盤查詢和管理的相關(guān)功能:包括查詢卷信息,對卷的掛載卸載、對磁盤分區(qū)以及卷的格式化等功能。
    的頭像 發(fā)表于 06-14 10:12 ?329次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發(fā)文件</b><b class='flag-5'>管理</b>:【@<b class='flag-5'>ohos</b>.volumeManager (卷<b class='flag-5'>管理</b>)】