js-apis-DataUriUtils.md 2.2 KB
Newer Older
W
wusongqing 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
# DataUriUtils Module

## Modules to Import

```js
import dataUriUtils from '@ohos.ability.dataUriUtils';
```

## DataUriUtils.getId

- Functionality

  Obtains the ID attached to the end of a given URI.

- Parameters


| Name| Readable/Writable| Type| Mandatory| Description|
| ---- | -------- | ------ | ---- | ------------------------- |
| uri  | Read-only| string | Yes| URI object from which the ID is to be obtained.|

- Return values

  Returns the ID obtained from the URI object.

- Example

```js
import dataUriUtils from '@ohos.ability.datauriutils'
dataUriUtils.getIdSync("com.example.dataUriUtils/1221")
```



## DataUriUtils.attachId

- Functionality

  Attaches an ID to the end of a given URI.

- Parameters


| Name| Readable/Writable| Type| Mandatory| Description|
| ---- | -------- | ------ | ---- | ------------------------- |
| uri  | Read-only| string | Yes| URI object to which an ID is to be attached.|
| id   | Read-only| number | Yes| ID to be attached.|

- Return values

  Returns the URI object with the ID attached.

- Example

```js
import dataUriUtils from '@ohos.ability.datauriutils'
var idint = 1122;
dataUriUtils.attachId(
    "com.example.dataUriUtils"
	idint,
)
```



## DataUriUtils.deleteId

- Functionality

  Deletes the ID from the end of a given URI.

- Parameters

  | Name| Readable/Writable| Type| Mandatory| Description|
  | ---- | -------- | ------ | ---- | ------------------------- |
  | uri  | Read-only| string | Yes| URI object from which the ID is to be deleted.|

- Return values

  Returns the URI object with the ID deleted.

- Example

```js
import dataUriUtils from '@ohos.ability.datauriutils'
dataUriUtils.deleteId("com.example.dataUriUtils/1221")
```



## DataUriUtils.updateId

- Functionality

  Updates the ID in a given URI.

- Parameters

  | Name| Readable/Writable| Type| Mandatory| Description|
  | ---- | -------- | ------ | ---- | ------------------- |
  | uri  | Read-only| string | Yes| URI object to be updated.|
  | id   | Read-only| number | Yes| New ID.|

- Return values

  Returns the URI object with the new ID.

- Example

```js
import dataUriUtils from '@ohos.ability.datauriutils'
var idint = 1122;
dataUriUtils.updateId(
    "com.example.dataUriUtils"
	idint,
)
```