1/* 2 * Copyright (C) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import type { AsyncCallback, Callback } from './@ohos.base'; 17import type Context from './application/Context'; 18import type image from './@ohos.multimedia.image'; 19import type dataSharePredicates from './@ohos.data.dataSharePredicates'; 20 21/** 22 * Helper functions to access image and video assets 23 * 24 * @namespace photoAccessHelper 25 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 26 * @since 10 27 */ 28declare namespace photoAccessHelper { 29 /** 30 * Returns an instance of PhotoAccessHelper 31 * 32 * @param { Context } context - Hap context information 33 * @returns { PhotoAccessHelper } Instance of PhotoAccessHelper 34 * @throws { BusinessError } 401 - if parameter is invalid 35 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 36 * @StageModelOnly 37 * @since 10 38 */ 39 function getPhotoAccessHelper(context: Context): PhotoAccessHelper; 40 41 /** 42 * Enumeration of different types of photos 43 * 44 * @enum { number } PhotoType 45 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 46 * @since 10 47 */ 48 enum PhotoType { 49 /** 50 * Image asset 51 * 52 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 53 * @since 10 54 */ 55 IMAGE = 1, 56 /** 57 * Video asset 58 * 59 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 60 * @since 10 61 */ 62 VIDEO 63 } 64 65 /** 66 * Enumeration of different categories of photos 67 * 68 * @enum { number } PhotoSubtype 69 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 70 * @systemapi 71 * @since 10 72 */ 73 enum PhotoSubtype { 74 /** 75 * Default Photo Type 76 * 77 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 78 * @systemapi 79 * @since 10 80 */ 81 DEFAULT, 82 /** 83 * Screenshot Photo Type 84 * 85 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 86 * @systemapi 87 * @since 10 88 */ 89 SCREENSHOT 90 } 91 92 /** 93 * Photo asset position 94 * 95 * @enum { number } Photo asset position, such as local device or cloud 96 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 97 * @systemapi 98 * @since 10 99 */ 100 enum PositionType { 101 /** 102 * Asset exists only in local device 103 * 104 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 105 * @systemapi 106 * @since 10 107 */ 108 LOCAL = 1 << 0, 109 /** 110 * Asset exists only in cloud 111 * 112 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 113 * @systemapi 114 * @since 10 115 */ 116 CLOUD = 1 << 1 117 } 118 119 /** 120 * Indicates the type of photo asset member. 121 * 122 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 123 * @since 10 124 */ 125 type MemberType = number | string | boolean; 126 127 /** 128 * Defines the photo asset 129 * 130 * @interface PhotoAsset 131 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 132 * @since 10 133 */ 134 interface PhotoAsset { 135 /** 136 * uri of the asset. 137 * 138 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 139 * @since 10 140 */ 141 readonly uri: string; 142 /** 143 * Photo type, image or video 144 * 145 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 146 * @since 10 147 */ 148 readonly photoType: PhotoType; 149 /** 150 * Display name (with a file name extension) of the asset. 151 * 152 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 153 * @since 10 154 */ 155 readonly displayName: string; 156 /** 157 * Returns the value of the specified member. 158 * 159 * @param { string } member - Photo asset member. for example : get(PhotoKeys.SIZE) 160 * @returns { MemberType } 161 * @throws { BusinessError } 401 - if parameter is invalid 162 * @throws { BusinessError } 13900020 - Invalid argument 163 * @throws { BusinessError } 14000014 - Member is not a valid PhotoKey 164 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 165 * @since 10 166 */ 167 get(member: string): MemberType; 168 /** 169 * Set a new value to the specified member 170 * 171 * @param { string } member - Photo asset member 172 * @param { string } value - The new value of the member. 173 * @throws { BusinessError } 401 - if parameter is invalid 174 * @throws { BusinessError } 13900020 - Invalid argument 175 * @throws { BusinessError } 14000014 - Member is not a valid PhotoKey 176 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 177 * @since 10 178 * @example : set(PhotoKeys.TITLE, "newTitle"), call commitModify after set 179 */ 180 set(member: string, value: string): void; 181 /** 182 * Modify metadata of the asset 183 * 184 * @permission ohos.permission.WRITE_IMAGEVIDEO 185 * @param { AsyncCallback<void> } callback - Returns void. 186 * @throws { BusinessError } 401 - if values to commit is invalid 187 * @throws { BusinessError } 13900012 - Permission denied 188 * @throws { BusinessError } 13900020 - Invalid argument 189 * @throws { BusinessError } 14000001 - Invalid display name 190 * @throws { BusinessError } 14000011 - System inner fail 191 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 192 * @since 10 193 */ 194 commitModify(callback: AsyncCallback<void>): void; 195 /** 196 * Modify metadata of the asset 197 * 198 * @permission ohos.permission.WRITE_IMAGEVIDEO 199 * @returns { Promise<void> } Returns void 200 * @throws { BusinessError } 401 - if values to commit is invalid 201 * @throws { BusinessError } 13900012 - Permission denied 202 * @throws { BusinessError } 13900020 - Invalid argument 203 * @throws { BusinessError } 14000001 - Invalid display name 204 * @throws { BusinessError } 14000011 - System inner fail 205 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 206 * @since 10 207 */ 208 commitModify(): Promise<void>; 209 /** 210 * Open the asset 211 * 212 * @permission ohos.permission.READ_IMAGEVIDEO or ohos.permission.WRITE_IMAGEVIDEO 213 * @param { string } mode - Mode for open, for example: rw, r, w. 214 * @param { AsyncCallback<number> } callback - Callback return the fd of the asset. 215 * @throws { BusinessError } 202 - Called by non-system application. 216 * @throws { BusinessError } 401 - if parameter is invalid 217 * @throws { BusinessError } 13900012 - Permission denied 218 * @throws { BusinessError } 13900020 - Invalid argument 219 * @throws { BusinessError } 14000011 - System inner fail 220 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 221 * @systemapi 222 * @since 10 223 */ 224 open(mode: string, callback: AsyncCallback<number>): void; 225 /** 226 * Open the asset 227 * 228 * @permission ohos.permission.READ_IMAGEVIDEO or ohos.permission.WRITE_IMAGEVIDEO 229 * @param { string } mode - Mode for open, for example: rw, r, w. 230 * @returns { Promise<number> } Returns the fd 231 * @throws { BusinessError } 202 - Called by non-system application. 232 * @throws { BusinessError } 401 - if parameter is invalid 233 * @throws { BusinessError } 13900012 - Permission denied 234 * @throws { BusinessError } 13900020 - Invalid argument 235 * @throws { BusinessError } 14000011 - System inner fail 236 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 237 * @systemapi 238 * @since 10 239 */ 240 open(mode: string): Promise<number>; 241 /** 242 * Open the asset in read only mode 243 * 244 * @permission ohos.permission.READ_IMAGEVIDEO 245 * @param { AsyncCallback<number> } callback - Returns the read only fd 246 * @throws { BusinessError } 401 - if parameter is invalid 247 * @throws { BusinessError } 13900012 - Permission denied 248 * @throws { BusinessError } 13900020 - Invalid argument 249 * @throws { BusinessError } 14000011 - System inner fail 250 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 251 * @since 10 252 */ 253 getReadOnlyFd(callback: AsyncCallback<number>): void; 254 /** 255 * Open the asset in read only mode 256 * 257 * @permission ohos.permission.READ_IMAGEVIDEO 258 * @returns { Promise<number> } Returns the read only fd 259 * @throws { BusinessError } 401 - if parameter is invalid 260 * @throws { BusinessError } 13900012 - Permission denied 261 * @throws { BusinessError } 13900020 - Invalid argument 262 * @throws { BusinessError } 14000011 - System inner fail 263 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 264 * @since 10 265 */ 266 getReadOnlyFd(): Promise<number>; 267 /** 268 * Close the asset 269 * 270 * @param { number } fd - The opened fd of the asset. 271 * @param { AsyncCallback<void> } callback - Returns void 272 * @throws { BusinessError } 401 - if parameter is invalid 273 * @throws { BusinessError } 13900020 - Invalid argument 274 * @throws { BusinessError } 14000011 - System inner fail 275 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 276 * @since 10 277 */ 278 close(fd: number, callback: AsyncCallback<void>): void; 279 /** 280 * Close the asset 281 * 282 * @param { number } fd - The opened fd of the asset. 283 * @returns { Promise<void> } Returns void 284 * @throws { BusinessError } 401 - if parameter is invalid 285 * @throws { BusinessError } 13900020 - Invalid argument 286 * @throws { BusinessError } 14000011 - System inner fail 287 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 288 * @since 10 289 */ 290 close(fd: number): Promise<void>; 291 /** 292 * Get thumbnail of the asset 293 * 294 * @permission ohos.permission.READ_IMAGEVIDEO 295 * @param { AsyncCallback<image.PixelMap> } callback - Returns the thumbnail's pixelMap. 296 * @throws { BusinessError } 401 - if parameter is invalid 297 * @throws { BusinessError } 13900012 - Permission denied 298 * @throws { BusinessError } 13900020 - Invalid argument 299 * @throws { BusinessError } 14000011 - System inner fail 300 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 301 * @since 10 302 */ 303 getThumbnail(callback: AsyncCallback<image.PixelMap>): void; 304 /** 305 * Get thumbnail of the asset 306 * 307 * @permission ohos.permission.READ_IMAGEVIDEO 308 * @param { image.Size } size - Thumbnail's size 309 * @param { AsyncCallback<image.PixelMap> } callback - Returns the thumbnail's pixelMap. 310 * @throws { BusinessError } 401 - if parameter is invalid 311 * @throws { BusinessError } 13900012 - Permission denied 312 * @throws { BusinessError } 13900020 - Invalid argument 313 * @throws { BusinessError } 14000011 - System inner fail 314 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 315 * @since 10 316 */ 317 getThumbnail(size: image.Size, callback: AsyncCallback<image.PixelMap>): void; 318 /** 319 * Get thumbnail of the asset 320 * 321 * @permission ohos.permission.READ_IMAGEVIDEO 322 * @param { image.Size } size - Thumbnail's size 323 * @returns { Promise<image.PixelMap> } Returns the thumbnail's pixelMap. 324 * @throws { BusinessError } 401 - if parameter is invalid 325 * @throws { BusinessError } 13900012 - Permission denied 326 * @throws { BusinessError } 13900020 - Invalid argument 327 * @throws { BusinessError } 14000011 - System inner fail 328 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 329 * @since 10 330 */ 331 getThumbnail(size?: image.Size): Promise<image.PixelMap>; 332 /** 333 * Set favorite state for the asset 334 * 335 * @permission ohos.permission.WRITE_IMAGEVIDEO 336 * @param { boolean } favoriteState - true: Put the asset into favorite album; false: Remove the asset from favorite album. 337 * @param { AsyncCallback<void> } callback - Returns void 338 * @throws { BusinessError } 202 - Called by non-system application. 339 * @throws { BusinessError } 401 - if parameter is invalid 340 * @throws { BusinessError } 13900012 - Permission denied 341 * @throws { BusinessError } 13900020 - Invalid argument 342 * @throws { BusinessError } 14000011 - System inner fail 343 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 344 * @systemapi 345 * @since 10 346 */ 347 setFavorite(favoriteState: boolean, callback: AsyncCallback<void>): void; 348 /** 349 * Set favorite state for the asset 350 * 351 * @permission ohos.permission.WRITE_IMAGEVIDEO 352 * @param { boolean } favoriteState - true: Put the asset into favorite album; false: Remove the asset from favorite album. 353 * @returns { Promise<void> } Returns void 354 * @throws { BusinessError } 202 - Called by non-system application. 355 * @throws { BusinessError } 401 - if parameter is invalid 356 * @throws { BusinessError } 13900012 - Permission denied 357 * @throws { BusinessError } 13900020 - Invalid argument 358 * @throws { BusinessError } 14000011 - System inner fail 359 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 360 * @systemapi 361 * @since 10 362 */ 363 setFavorite(favoriteState: boolean): Promise<void>; 364 /** 365 * Set asset hidden state. 366 * 367 * @permission ohos.permission.WRITE_IMAGEVIDEO 368 * @param { boolean } hiddenState - true: Put the asset into hidden album; false: Recover the asset from hidden album. 369 * @param { AsyncCallback<void> } callback - Returns void. 370 * @throws { BusinessError } 202 - Called by non-system application. 371 * @throws { BusinessError } 401 - if parameter is invalid 372 * @throws { BusinessError } 13900012 - Permission denied 373 * @throws { BusinessError } 13900020 - Invalid argument 374 * @throws { BusinessError } 14000011 - System inner fail 375 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 376 * @systemapi 377 * @since 10 378 */ 379 setHidden(hiddenState: boolean, callback: AsyncCallback<void>): void; 380 /** 381 * Set asset hidden state. 382 * 383 * @permission ohos.permission.WRITE_IMAGEVIDEO 384 * @param { boolean } hiddenState - true: Put the asset into hidden album; false: Recover the asset from hidden album. 385 * @returns { Promise<void> } Returns the promise 386 * @throws { BusinessError } 202 - Called by non-system application. 387 * @throws { BusinessError } 401 - if parameter is invalid 388 * @throws { BusinessError } 13900012 - Permission denied 389 * @throws { BusinessError } 13900020 - Invalid argument 390 * @throws { BusinessError } 14000011 - System inner fail 391 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 392 * @systemapi 393 * @since 10 394 */ 395 setHidden(hiddenState: boolean): Promise<void>; 396 /** 397 * Set user comment info to the asset. 398 * 399 * @permission ohos.permission.WRITE_IMAGEVIDEO 400 * @param { string } userComment - user comment info 401 * @param { AsyncCallback<void> } callback - Returns void. 402 * @throws { BusinessError } 202 - Called by non-system application. 403 * @throws { BusinessError } 401 - if parameter is invalid 404 * @throws { BusinessError } 13900012 - Permission denied 405 * @throws { BusinessError } 13900020 - Invalid argument 406 * @throws { BusinessError } 14000011 - System inner fail 407 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 408 * @systemapi 409 * @since 10 410 */ 411 setUserComment(userComment: string, callback: AsyncCallback<void>): void; 412 /** 413 * Set user comment info to the asset. 414 * 415 * @permission ohos.permission.WRITE_IMAGEVIDEO 416 * @param { string } userComment - user comment info 417 * @returns { Promise<void> } Returns void 418 * @throws { BusinessError } 202 - Called by non-system application. 419 * @throws { BusinessError } 401 - if parameter is invalid 420 * @throws { BusinessError } 13900012 - Permission denied 421 * @throws { BusinessError } 13900020 - Invalid argument 422 * @throws { BusinessError } 14000011 - System inner fail 423 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 424 * @systemapi 425 * @since 10 426 */ 427 setUserComment(userComment: string): Promise<void>; 428 /** 429 * Get exif info of the asset. 430 * 431 * @permission ohos.permission.READ_IMAGEVIDEO 432 * @param { AsyncCallback<string> } callback - Returns exif info into a json string 433 * @throws { BusinessError } 202 - Called by non-system application. 434 * @throws { BusinessError } 401 - if parameter is invalid 435 * @throws { BusinessError } 13900012 - Permission denied 436 * @throws { BusinessError } 13900020 - Invalid argument 437 * @throws { BusinessError } 14000011 - System inner fail 438 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 439 * @systemapi 440 * @since 10 441 */ 442 getExif(callback: AsyncCallback<string>): void; 443 /** 444 * Get exif info of the asset. 445 * 446 * @permission ohos.permission.READ_IMAGEVIDEO 447 * @returns { Promise<string> } Returns exif info into a json string 448 * @throws { BusinessError } 202 - Called by non-system application. 449 * @throws { BusinessError } 401 - if parameter is invalid 450 * @throws { BusinessError } 13900012 - Permission denied 451 * @throws { BusinessError } 13900020 - Invalid argument 452 * @throws { BusinessError } 14000011 - System inner fail 453 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 454 * @systemapi 455 * @since 10 456 */ 457 getExif(): Promise<string>; 458 } 459 460 /** 461 * Enumeration of photo asset members 462 * 463 * @enum { string } PhotoKeys 464 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 465 * @since 10 466 */ 467 enum PhotoKeys { 468 /** 469 * Asset uri, read only 470 * 471 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 472 * @since 10 473 */ 474 URI = 'uri', 475 /** 476 * Photo type of the asset, read only 477 * 478 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 479 * @since 10 480 */ 481 PHOTO_TYPE = 'media_type', 482 /** 483 * Asset name, read only 484 * 485 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 486 * @since 10 487 */ 488 DISPLAY_NAME = 'display_name', 489 /** 490 * Size of the asset, read only 491 * 492 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 493 * @since 10 494 */ 495 SIZE = 'size', 496 /** 497 * Creation date of the asset, read only 498 * 499 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 500 * @since 10 501 */ 502 DATE_ADDED = 'date_added', 503 /** 504 * Modified date of the asset, read only 505 * 506 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 507 * @since 10 508 */ 509 DATE_MODIFIED = 'date_modified', 510 /** 511 * Duration of video files, read only 512 * 513 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 514 * @since 10 515 */ 516 DURATION = 'duration', 517 /** 518 * Width of the image asset, read only 519 * 520 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 521 * @since 10 522 */ 523 WIDTH = 'width', 524 /** 525 * Height of the image asset, read only 526 * 527 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 528 * @since 10 529 */ 530 HEIGHT = 'height', 531 /** 532 * Date taken of the asset, read only 533 * 534 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 535 * @since 10 536 */ 537 DATE_TAKEN = 'date_taken', 538 /** 539 * Orientation of the image asset, read only 540 * 541 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 542 * @since 10 543 */ 544 ORIENTATION = 'orientation', 545 /** 546 * Favorite state of the asset, read only 547 * 548 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 549 * @since 10 550 */ 551 FAVORITE = 'is_favorite', 552 /** 553 * Title of the asset 554 * 555 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 556 * @since 10 557 */ 558 TITLE = 'title', 559 /** 560 * Asset position, read only 561 * 562 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 563 * @systemapi 564 * @since 10 565 */ 566 POSITION = 'position', 567 /** 568 * Trashed date of the asset, read only 569 * 570 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 571 * @systemapi 572 * @since 10 573 */ 574 DATE_TRASHED = 'date_trashed', 575 /** 576 * Hidden state of the asset, read only 577 * 578 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 579 * @systemapi 580 * @since 10 581 */ 582 HIDDEN = 'hidden', 583 /** 584 * User comment info 585 * 586 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 587 * @systemapi 588 * @since 10 589 */ 590 USER_COMMENT = 'user_comment', 591 /** 592 * Camera shot key 593 * 594 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 595 * @systemapi 596 * @since 10 597 */ 598 CAMERA_SHOT_KEY = 'camera_shot_key' 599 } 600 601 /** 602 * Enumeration of photo album members. 603 * 604 * @enum { string } AlbumKeys 605 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 606 * @since 10 607 */ 608 enum AlbumKeys { 609 /** 610 * Album uri 611 * 612 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 613 * @since 10 614 */ 615 URI = 'uri', 616 /** 617 * Album name 618 * 619 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 620 * @since 10 621 */ 622 ALBUM_NAME = 'album_name' 623 } 624 625 /** 626 * Options to fetch assets or albums 627 * 628 * @interface FetchOptions 629 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 630 * @since 10 631 */ 632 interface FetchOptions { 633 /** 634 * Indicates the members to query. 635 * 636 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 637 * @since 10 638 */ 639 fetchColumns: Array<string>; 640 /** 641 * Predicates to query 642 * 643 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 644 * @since 10 645 */ 646 predicates: dataSharePredicates.DataSharePredicates; 647 } 648 649 /** 650 * Options to create a photo asset for system apps 651 * 652 * @interface PhotoCreateOptions 653 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 654 * @systemapi 655 * @since 10 656 */ 657 interface PhotoCreateOptions { 658 /** 659 * Specify subtype of the asset to create 660 * 661 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 662 * @systemapi 663 * @since 10 664 */ 665 subtype?: PhotoSubtype; 666 /** 667 * Camera shot key 668 * 669 * @type { ?string } 670 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 671 * @systemapi 672 * @since 10 673 */ 674 cameraShotKey?: string; 675 } 676 677 /** 678 * Options to create a photo asset 679 * 680 * @interface CreateOptions 681 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 682 * @since 10 683 */ 684 interface CreateOptions { 685 /** 686 * Title of the asset 687 * 688 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 689 * @since 10 690 */ 691 title?: string; 692 } 693 694 /** 695 * The fetch result of assets or albums 696 * 697 * @interface FetchResult 698 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 699 * @since 10 700 */ 701 interface FetchResult<T> { 702 /** 703 * Obtains the total number of objects in the fetch result. 704 * 705 * @returns { number } Total number of objects. 706 * @throws { BusinessError } 401 - if parameter is invalid 707 * @throws { BusinessError } 13900020 - Invalid argument 708 * @throws { BusinessError } 14000011 - System inner fail 709 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 710 * @since 10 711 */ 712 getCount(): number; 713 /** 714 * Checks whether the result set points to the last row. 715 * You need to check whether the object is the last one before calling getNextObject. 716 * 717 * @returns { boolean } Whether the object is the last one in the fetch result. 718 * @throws { BusinessError } 401 - if parameter is invalid 719 * @throws { BusinessError } 13900020 - Invalid argument 720 * @throws { BusinessError } 14000011 - System inner fail 721 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 722 * @since 10 723 */ 724 isAfterLast(): boolean; 725 /** 726 * Obtains the first object in the fetch result. 727 * 728 * @param { AsyncCallback<T> } callback - Returns the first object in the fetch result. 729 * @throws { BusinessError } 401 - if parameter is invalid 730 * @throws { BusinessError } 13900020 - Invalid argument 731 * @throws { BusinessError } 14000011 - System inner fail 732 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 733 * @since 10 734 */ 735 getFirstObject(callback: AsyncCallback<T>): void; 736 /** 737 * Obtains the first object in the fetch result. 738 * 739 * @returns { Promise<T> } Returns the first object in the fetch result. 740 * @throws { BusinessError } 401 - if parameter is invalid 741 * @throws { BusinessError } 13900020 - Invalid argument 742 * @throws { BusinessError } 14000011 - System inner fail 743 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 744 * @since 10 745 */ 746 getFirstObject(): Promise<T>; 747 /** 748 * Obtains the next object in the fetch result. 749 * Before calling this method, you must use isAfterLast() to check whether the current position is the last row 750 * in the fetch result. This method only works when the current position is not the last row. 751 * 752 * @param { AsyncCallback<T> } callback - Returns the next object 753 * @throws { BusinessError } 401 - if parameter is invalid 754 * @throws { BusinessError } 13900020 - Invalid argument 755 * @throws { BusinessError } 14000011 - System inner fail 756 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 757 * @since 10 758 */ 759 getNextObject(callback: AsyncCallback<T>): void; 760 /** 761 * Obtains the next object in the fetch result. 762 * Before calling this method, you must use isAfterLast() to check whether the current position is the last row 763 * in the fetch result. This method only works when the current position is not the last row. 764 * 765 * @returns { Promise<T> } Returns the next object 766 * @throws { BusinessError } 401 - if parameter is invalid 767 * @throws { BusinessError } 13900020 - Invalid argument 768 * @throws { BusinessError } 14000011 - System inner fail 769 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 770 * @since 10 771 */ 772 getNextObject(): Promise<T>; 773 /** 774 * Obtains the last object in the fetch result 775 * 776 * @param { AsyncCallback<T> } callback - Returns the last object 777 * @throws { BusinessError } 401 - if parameter is invalid 778 * @throws { BusinessError } 13900020 - Invalid argument 779 * @throws { BusinessError } 14000011 - System inner fail 780 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 781 * @since 10 782 */ 783 getLastObject(callback: AsyncCallback<T>): void; 784 /** 785 * Obtains the last object in the fetch result 786 * 787 * @returns { Promise<T> } Returns the last object 788 * @throws { BusinessError } 401 - if parameter is invalid 789 * @throws { BusinessError } 13900020 - Invalid argument 790 * @throws { BusinessError } 14000011 - System inner fail 791 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 792 * @since 10 793 */ 794 getLastObject(): Promise<T>; 795 /** 796 * Obtains the object with the specified index in the fetch result. 797 * 798 * @param { number } index - Index of the object to obtain. 799 * @param { AsyncCallback<T> } callback - Returns the object 800 * @throws { BusinessError } 401 - if type index is not number 801 * @throws { BusinessError } 13900020 - Invalid argument 802 * @throws { BusinessError } 14000011 - System inner fail 803 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 804 * @since 10 805 */ 806 getObjectByPosition(index: number, callback: AsyncCallback<T>): void; 807 /** 808 * Obtains the object with the specified index in the fetch result. 809 * 810 * @param { number } index - Index of the asset to obtain. 811 * @returns { Promise<T> } Returns the object 812 * @throws { BusinessError } 401 - if type index is not number 813 * @throws { BusinessError } 13900020 - Invalid argument 814 * @throws { BusinessError } 14000011 - System inner fail 815 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 816 * @since 10 817 */ 818 getObjectByPosition(index: number): Promise<T>; 819 /** 820 * Obtains all objects in the fetch result. 821 * 822 * @param { AsyncCallback<Array<T>> } callback - Returns all the objects 823 * @throws { BusinessError } 401 - if parameter is invalid 824 * @throws { BusinessError } 13900020 - Invalid argument 825 * @throws { BusinessError } 14000011 - System inner fail 826 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 827 * @since 10 828 */ 829 getAllObjects(callback: AsyncCallback<Array<T>>): void; 830 /** 831 * Obtains all objects in the fetch result. 832 * 833 * @returns { Promise<Array<T>> } Returns all the objects 834 * @throws { BusinessError } 401 - if parameter is invalid 835 * @throws { BusinessError } 13900020 - Invalid argument 836 * @throws { BusinessError } 14000011 - System inner fail 837 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 838 * @since 10 839 */ 840 getAllObjects(): Promise<Array<T>>; 841 /** 842 * Releases the fetch result. 843 * 844 * @throws { BusinessError } 401 - if parameter is invalid 845 * @throws { BusinessError } 13900020 - Invalid argument 846 * @throws { BusinessError } 14000011 - System inner fail 847 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 848 * @since 10 849 */ 850 close(): void; 851 } 852 853 /** 854 * Album type. 855 * 856 * @enum { number } AlbumType 857 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 858 * @since 10 859 */ 860 enum AlbumType { 861 /** 862 * Album created by user. 863 * 864 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 865 * @since 10 866 */ 867 USER = 0, 868 /** 869 * Album created by system, which metadata cannot be modified. 870 * 871 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 872 * @since 10 873 */ 874 SYSTEM = 1024 875 } 876 877 /** 878 * Album subtype 879 * 880 * @enum { number } AlbumSubtype 881 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 882 * @since 10 883 */ 884 enum AlbumSubtype { 885 /** 886 * Generic user-created albums. 887 * 888 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 889 * @since 10 890 */ 891 USER_GENERIC = 1, 892 /** 893 * Favorite album, which assets are marked as favorite. 894 * 895 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 896 * @since 10 897 */ 898 FAVORITE = 1025, 899 /** 900 * Video album, which contains all video assets. 901 * 902 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 903 * @since 10 904 */ 905 VIDEO, 906 /** 907 * Hidden album, which assets are marked as hidden. 908 * 909 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 910 * @systemapi 911 * @since 10 912 */ 913 HIDDEN, 914 /** 915 * Trash album, which assets are deleted. 916 * 917 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 918 * @systemapi 919 * @since 10 920 */ 921 TRASH, 922 /** 923 * Screenshot album 924 * 925 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 926 * @systemapi 927 * @since 10 928 */ 929 SCREENSHOT, 930 /** 931 * Camera album 932 * 933 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 934 * @systemapi 935 * @since 10 936 */ 937 CAMERA, 938 /** 939 * Any album 940 * 941 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 942 * @since 10 943 */ 944 ANY = 2147483647 945 } 946 947 /** 948 * Defines the abstract interface of albums. 949 * 950 * @interface AbsAlbum 951 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 952 * @since 10 953 */ 954 interface AbsAlbum { 955 /** 956 * Album type 957 * 958 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 959 * @since 10 960 */ 961 readonly albumType: AlbumType; 962 /** 963 * Album subtype 964 * 965 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 966 * @since 10 967 */ 968 readonly albumSubtype: AlbumSubtype; 969 /** 970 * Album name. 971 * 972 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 973 * @since 10 974 */ 975 albumName: string; 976 /** 977 * Album uri. 978 * 979 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 980 * @since 10 981 */ 982 readonly albumUri: string; 983 /** 984 * Number of assets in the album 985 * 986 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 987 * @since 10 988 */ 989 readonly count: number; 990 /** 991 * Cover uri for the album 992 * 993 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 994 * @since 10 995 */ 996 readonly coverUri: string; 997 /** 998 * Fetch assets in an album. 999 * 1000 * @permission ohos.permission.READ_IMAGEVIDEO 1001 * @param { FetchOptions } options - Fetch options. 1002 * @param { AsyncCallback<FetchResult<PhotoAsset>> } callback - Returns the fetch result 1003 * @throws { BusinessError } 401 - if type options is not FetchOptions 1004 * @throws { BusinessError } 13900012 - Permission denied 1005 * @throws { BusinessError } 13900020 - Invalid argument 1006 * @throws { BusinessError } 14000011 - System inner fail 1007 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1008 * @since 10 1009 */ 1010 getAssets(options: FetchOptions, callback: AsyncCallback<FetchResult<PhotoAsset>>): void; 1011 /** 1012 * Fetch assets in an album. 1013 * 1014 * @permission ohos.permission.READ_IMAGEVIDEO 1015 * @param { FetchOptions } options - Fetch options. 1016 * @returns { Promise<FetchResult<PhotoAsset>> } Returns the fetch result 1017 * @throws { BusinessError } 401 - if type options is not FetchOptions 1018 * @throws { BusinessError } 13900012 - Permission denied 1019 * @throws { BusinessError } 13900020 - Invalid argument 1020 * @throws { BusinessError } 14000011 - System inner fail 1021 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1022 * @since 10 1023 */ 1024 getAssets(options: FetchOptions): Promise<FetchResult<PhotoAsset>>; 1025 } 1026 1027 /** 1028 * Defines the album. 1029 * 1030 * @interface Album 1031 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1032 * @since 10 1033 */ 1034 interface Album extends AbsAlbum { 1035 /** 1036 * Modify metadata for the album 1037 * 1038 * @permission ohos.permission.WRITE_IMAGEVIDEO 1039 * @param { AsyncCallback<void> } callback - Returns void 1040 * @throws { BusinessError } 401 - if value to modify is invalid 1041 * @throws { BusinessError } 13900012 - Permission denied 1042 * @throws { BusinessError } 13900020 - Invalid argument 1043 * @throws { BusinessError } 14000011 - System inner fail 1044 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1045 * @since 10 1046 */ 1047 commitModify(callback: AsyncCallback<void>): void; 1048 /** 1049 * Modify metadata for the album 1050 * 1051 * @permission ohos.permission.WRITE_IMAGEVIDEO 1052 * @returns { Promise<void> } Returns void 1053 * @throws { BusinessError } 401 - if value to modify is invalid 1054 * @throws { BusinessError } 13900012 - Permission denied 1055 * @throws { BusinessError } 13900020 - Invalid argument 1056 * @throws { BusinessError } 14000011 - System inner fail 1057 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1058 * @since 10 1059 */ 1060 commitModify(): Promise<void>; 1061 /** 1062 * Add assets to the album. 1063 * 1064 * @permission ohos.permission.WRITE_IMAGEVIDEO 1065 * @param { Array<PhotoAsset> } assets - Assets to add 1066 * @param { AsyncCallback<void> } callback - Returns void 1067 * @throws { BusinessError } 401 - if PhotoAssets is invalid 1068 * @throws { BusinessError } 13900012 - Permission denied 1069 * @throws { BusinessError } 13900020 - Invalid argument 1070 * @throws { BusinessError } 14000011 - System inner fail 1071 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1072 * @since 10 1073 */ 1074 addAssets(assets: Array<PhotoAsset>, callback: AsyncCallback<void>): void; 1075 /** 1076 * Add assets to the album. 1077 * 1078 * @permission ohos.permission.WRITE_IMAGEVIDEO 1079 * @param { Array<PhotoAsset> } assets - Assets to add 1080 * @returns { Promise<void> } Returns void 1081 * @throws { BusinessError } 401 - if PhotoAssets is invalid 1082 * @throws { BusinessError } 13900012 - Permission denied 1083 * @throws { BusinessError } 13900020 - Invalid argument 1084 * @throws { BusinessError } 14000011 - System inner fail 1085 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1086 * @since 10 1087 */ 1088 addAssets(assets: Array<PhotoAsset>): Promise<void>; 1089 /** 1090 * Remove assets from the album. 1091 * 1092 * @permission ohos.permission.WRITE_IMAGEVIDEO 1093 * @param { Array<PhotoAsset> } assets - Assets to remove 1094 * @param { AsyncCallback<void> } callback - Returns void 1095 * @throws { BusinessError } 401 - if PhotoAssets is invalid 1096 * @throws { BusinessError } 13900012 - Permission denied 1097 * @throws { BusinessError } 13900020 - Invalid argument 1098 * @throws { BusinessError } 14000011 - System inner fail 1099 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1100 * @since 10 1101 */ 1102 removeAssets(assets: Array<PhotoAsset>, callback: AsyncCallback<void>): void; 1103 /** 1104 * Remove assets from the album. 1105 * 1106 * @permission ohos.permission.WRITE_IMAGEVIDEO 1107 * @param { Array<PhotoAsset> } assets - Assets to remove 1108 * @returns { Promise<void> } Returns the promise 1109 * @throws { BusinessError } 401 - if PhotoAssets is invalid 1110 * @throws { BusinessError } 13900012 - Permission denied 1111 * @throws { BusinessError } 13900020 - Invalid argument 1112 * @throws { BusinessError } 14000011 - System inner fail 1113 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1114 * @since 10 1115 */ 1116 removeAssets(assets: Array<PhotoAsset>): Promise<void>; 1117 /** 1118 * Recover assets from the trash album. 1119 * 1120 * @permission ohos.permission.WRITE_IMAGEVIDEO 1121 * @param { Array<PhotoAsset> } assets - Assets to recover 1122 * @param { AsyncCallback<void> } callback - Returns void 1123 * @throws { BusinessError } 202 - Called by non-system application. 1124 * @throws { BusinessError } 401 - if PhotoAssets is invalid 1125 * @throws { BusinessError } 13900012 - Permission denied 1126 * @throws { BusinessError } 13900020 - Invalid argument 1127 * @throws { BusinessError } 14000011 - System inner fail 1128 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1129 * @systemapi 1130 * @since 10 1131 */ 1132 recoverAssets(assets: Array<PhotoAsset>, callback: AsyncCallback<void>): void; 1133 /** 1134 * Recover assets from the trash album. 1135 * 1136 * @permission ohos.permission.WRITE_IMAGEVIDEO 1137 * @param { Array<PhotoAsset> } assets - Assets to recover 1138 * @returns { Promise<void> } Returns the promise 1139 * @throws { BusinessError } 202 - Called by non-system application. 1140 * @throws { BusinessError } 401 - if PhotoAssets is invalid 1141 * @throws { BusinessError } 13900012 - Permission denied 1142 * @throws { BusinessError } 13900020 - Invalid argument 1143 * @throws { BusinessError } 14000011 - System inner fail 1144 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1145 * @systemapi 1146 * @since 10 1147 */ 1148 recoverAssets(assets: Array<PhotoAsset>): Promise<void>; 1149 /** 1150 * Delete assets permanently from the trash album. 1151 * 1152 * @permission ohos.permission.WRITE_IMAGEVIDEO 1153 * @param { Array<PhotoAsset> } assets - Assets to delete 1154 * @param { AsyncCallback<void> } callback - Returns void 1155 * @throws { BusinessError } 202 - Called by non-system application. 1156 * @throws { BusinessError } 401 - if PhotoAssets is invalid 1157 * @throws { BusinessError } 13900012 - Permission denied 1158 * @throws { BusinessError } 13900020 - Invalid argument 1159 * @throws { BusinessError } 14000011 - System inner fail 1160 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1161 * @systemapi 1162 * @since 10 1163 */ 1164 deleteAssets(assets: Array<PhotoAsset>, callback: AsyncCallback<void>): void; 1165 /** 1166 * Delete assets permanently from the trash album. 1167 * 1168 * @permission ohos.permission.WRITE_IMAGEVIDEO 1169 * @param { Array<PhotoAsset> } assets - Assets to delete 1170 * @returns { Promise<void> } Returns the promise 1171 * @throws { BusinessError } 202 - Called by non-system application. 1172 * @throws { BusinessError } 401 - if PhotoAssets is invalid 1173 * @throws { BusinessError } 13900012 - Permission denied 1174 * @throws { BusinessError } 13900020 - Invalid argument 1175 * @throws { BusinessError } 14000011 - System inner fail 1176 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1177 * @systemapi 1178 * @since 10 1179 */ 1180 deleteAssets(assets: Array<PhotoAsset>): Promise<void>; 1181 /** 1182 * Set cover uri for this album. 1183 * 1184 * @permission ohos.permission.WRITE_IMAGEVIDEO 1185 * @param { string } uri - The asset uri to set 1186 * @param { AsyncCallback<void> } callback - Returns void 1187 * @throws { BusinessError } 202 - Called by non-system application. 1188 * @throws { BusinessError } 401 - if parameter is invalid 1189 * @throws { BusinessError } 13900012 - Permission denied 1190 * @throws { BusinessError } 13900020 - Invalid argument 1191 * @throws { BusinessError } 14000011 - System inner fail 1192 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1193 * @systemapi 1194 * @since 10 1195 */ 1196 setCoverUri(uri: string, callback: AsyncCallback<void>): void; 1197 /** 1198 * Set cover uri for this album. 1199 * 1200 * @permission ohos.permission.WRITE_IMAGEVIDEO 1201 * @param { string } uri - The asset uri to set 1202 * @returns { Promise<void> } Returns void 1203 * @throws { BusinessError } 202 - Called by non-system application. 1204 * @throws { BusinessError } 401 - if parameter is invalid 1205 * @throws { BusinessError } 13900012 - Permission denied 1206 * @throws { BusinessError } 13900020 - Invalid argument 1207 * @throws { BusinessError } 14000011 - System inner fail 1208 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1209 * @systemapi 1210 * @since 10 1211 */ 1212 setCoverUri(uri: string): Promise<void>; 1213 } 1214 1215 /** 1216 * Helper functions to access photos and albums. 1217 * 1218 * @interface PhotoAccessHelper 1219 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1220 * @since 10 1221 */ 1222 interface PhotoAccessHelper { 1223 /** 1224 * Fetch photo assets 1225 * 1226 * @permission ohos.permission.READ_IMAGEVIDEO 1227 * @param { FetchOptions } options - Fetch options. 1228 * @param { AsyncCallback<FetchResult<PhotoAsset>> } callback - Returns the fetch result. 1229 * @throws { BusinessError } 401 - if type options is not FetchOptions 1230 * @throws { BusinessError } 13900012 - Permission denied 1231 * @throws { BusinessError } 13900020 - Invalid argument 1232 * @throws { BusinessError } 14000011 - System inner fail 1233 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1234 * @since 10 1235 */ 1236 getAssets(options: FetchOptions, callback: AsyncCallback<FetchResult<PhotoAsset>>): void; 1237 /** 1238 * Fetch photo assets 1239 * 1240 * @permission ohos.permission.READ_IMAGEVIDEO 1241 * @param { FetchOptions } options - Retrieval options. 1242 * @returns { Promise<FetchResult<PhotoAsset>> } Returns the fetch result. 1243 * @throws { BusinessError } 401 - if type options is not FetchOptions 1244 * @throws { BusinessError } 13900012 - Permission denied 1245 * @throws { BusinessError } 13900020 - Invalid argument 1246 * @throws { BusinessError } 14000011 - System inner fail 1247 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1248 * @since 10 1249 */ 1250 getAssets(options: FetchOptions): Promise<FetchResult<PhotoAsset>>; 1251 /** 1252 * Create a photo asset 1253 * 1254 * @permission ohos.permission.WRITE_IMAGEVIDEO 1255 * @param { string } displayName - Asset name 1256 * @param { AsyncCallback<PhotoAsset> } callback - Returns the newly created asset 1257 * @throws { BusinessError } 202 - Called by non-system application. 1258 * @throws { BusinessError } 401 - if type displayName is not string 1259 * @throws { BusinessError } 13900012 - Permission denied 1260 * @throws { BusinessError } 13900020 - Invalid argument 1261 * @throws { BusinessError } 14000001 - Invalid display name 1262 * @throws { BusinessError } 14000011 - System inner fail 1263 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1264 * @systemapi 1265 * @since 10 1266 */ 1267 createAsset(displayName: string, callback: AsyncCallback<PhotoAsset>): void; 1268 /** 1269 * Create a photo asset 1270 * 1271 * @permission ohos.permission.WRITE_IMAGEVIDEO 1272 * @param { string } displayName - Asset name 1273 * @returns { Promise<PhotoAsset> } Returns the newly created asset 1274 * @throws { BusinessError } 202 - Called by non-system application. 1275 * @throws { BusinessError } 401 - if type displayName or albumUri is not string 1276 * @throws { BusinessError } 13900012 - Permission denied 1277 * @throws { BusinessError } 13900020 - Invalid argument 1278 * @throws { BusinessError } 14000001 - Invalid display name 1279 * @throws { BusinessError } 14000011 - System inner fail 1280 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1281 * @systemapi 1282 * @since 10 1283 */ 1284 createAsset(displayName: string): Promise<PhotoAsset>; 1285 /** 1286 * Create a photo asset 1287 * 1288 * @permission ohos.permission.WRITE_IMAGEVIDEO 1289 * @param { string } displayName - Asset name 1290 * @param { PhotoCreateOptions } options - Create operation 1291 * @returns { Promise<PhotoAsset> } Returns the newly created asset 1292 * @throws { BusinessError } 202 - Called by non-system application. 1293 * @throws { BusinessError } 401 - if type displayName is not string 1294 * @throws { BusinessError } 13900012 - Permission denied 1295 * @throws { BusinessError } 13900020 - Invalid argument 1296 * @throws { BusinessError } 14000001 - Invalid display name 1297 * @throws { BusinessError } 14000011 - System inner fail 1298 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1299 * @systemapi 1300 * @since 10 1301 */ 1302 createAsset(displayName: string, options: PhotoCreateOptions): Promise<PhotoAsset>; 1303 /** 1304 * Create a photo asset 1305 * 1306 * @permission ohos.permission.WRITE_IMAGEVIDEO 1307 * @param { string } displayName - Asset name 1308 * @param { PhotoCreateOptions } options - Photo create operation 1309 * @param { AsyncCallback<PhotoAsset> } callback - Returns the newly created asset 1310 * @throws { BusinessError } 202 - Called by non-system application. 1311 * @throws { BusinessError } 401 - if type displayName is not string 1312 * @throws { BusinessError } 13900012 - Permission denied 1313 * @throws { BusinessError } 13900020 - Invalid argument 1314 * @throws { BusinessError } 14000001 - Invalid display name 1315 * @throws { BusinessError } 14000011 - System inner fail 1316 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1317 * @systemapi 1318 * @since 10 1319 */ 1320 createAsset(displayName: string, options: PhotoCreateOptions, callback: AsyncCallback<PhotoAsset>): void; 1321 /** 1322 * Create a photo asset: 1323 * 1. (Suggested)Integrate security component without WRITE_IMAGEVIDEO permission; 1324 * 2. Get WRITE_IMAGEVIDEO permission by ACL; 1325 * 1326 * @permission ohos.permission.WRITE_IMAGEVIDEO 1327 * @param { PhotoType } photoType - Photo asset type 1328 * @param { string } extension - Asset extension 1329 * @param { CreateOptions } options - Asset create option 1330 * @param { AsyncCallback<string> } callback - Returns the uri of the newly created asset 1331 * @throws { BusinessError } 401 - if type createOption is wrong 1332 * @throws { BusinessError } 13900012 - Permission denied 1333 * @throws { BusinessError } 13900020 - Invalid argument 1334 * @throws { BusinessError } 14000011 - System inner fail 1335 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1336 * @since 10 1337 */ 1338 createAsset(photoType: PhotoType, extension: string, options: CreateOptions, callback: AsyncCallback<string>): void; 1339 /** 1340 * Create a photo asset: 1341 * 1. (Suggested)Integrate security component without WRITE_IMAGEVIDEO permission; 1342 * 2. Get WRITE_IMAGEVIDEO permission by ACL; 1343 * 1344 * @permission ohos.permission.WRITE_IMAGEVIDEO 1345 * @param { PhotoType } photoType - Photo asset type 1346 * @param { string } extension - Asset extension 1347 * @param { AsyncCallback<string> } callback - Returns the uri of the newly created asset 1348 * @throws { BusinessError } 401 - if type createOption is wrong 1349 * @throws { BusinessError } 13900012 - Permission denied 1350 * @throws { BusinessError } 13900020 - Invalid argument 1351 * @throws { BusinessError } 14000011 - System inner fail 1352 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1353 * @since 10 1354 */ 1355 createAsset(photoType: PhotoType, extension: string, callback: AsyncCallback<string>): void; 1356 /** 1357 * Create a photo asset: 1358 * 1. (Suggested)Integrate security component without WRITE_IMAGEVIDEO permission; 1359 * 2. Get WRITE_IMAGEVIDEO permission by ACL; 1360 * 1361 * @permission ohos.permission.WRITE_IMAGEVIDEO 1362 * @param { PhotoType } photoType - Photo asset type 1363 * @param { string } extension - Asset extension 1364 * @param { CreateOptions } [options] - Optional asset create option 1365 * @returns { Promise<string> } Returns the uri of the newly created asset 1366 * @throws { BusinessError } 401 - if type createOption is wrong 1367 * @throws { BusinessError } 13900012 - Permission denied 1368 * @throws { BusinessError } 13900020 - Invalid argument 1369 * @throws { BusinessError } 14000011 - System inner fail 1370 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1371 * @since 10 1372 */ 1373 createAsset(photoType: PhotoType, extension: string, options?: CreateOptions): Promise<string>; 1374 /** 1375 * Create a generic user album. 1376 * 1377 * @permission ohos.permission.WRITE_IMAGEVIDEO 1378 * @param { string } name - Album name to be created. 1379 * @param { AsyncCallback<Album> } callback - Returns the instance of newly created Album 1380 * @throws { BusinessError } 202 - Called by non-system application. 1381 * @throws { BusinessError } 401 - if parameter is invalid 1382 * @throws { BusinessError } 13900012 - Permission denied 1383 * @throws { BusinessError } 13900015 - File exists 1384 * @throws { BusinessError } 13900020 - Invalid argument 1385 * @throws { BusinessError } 14000011 - System inner fail 1386 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1387 * @systemapi 1388 * @since 10 1389 */ 1390 createAlbum(name: string, callback: AsyncCallback<Album>): void; 1391 /** 1392 * Create a generic user album. 1393 * 1394 * @permission ohos.permission.WRITE_IMAGEVIDEO 1395 * @param { string } name - Album name to be created. 1396 * @returns { Promise<Album> } Returns the instance of newly created Album 1397 * @throws { BusinessError } 202 - Called by non-system application. 1398 * @throws { BusinessError } 401 - if parameter is invalid 1399 * @throws { BusinessError } 13900012 - Permission denied 1400 * @throws { BusinessError } 13900015 - File exists 1401 * @throws { BusinessError } 13900020 - Invalid argument 1402 * @throws { BusinessError } 14000011 - System inner fail 1403 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1404 * @systemapi 1405 * @since 10 1406 */ 1407 createAlbum(name: string): Promise<Album>; 1408 /** 1409 * Delete generic user-created albums. 1410 * 1411 * @permission ohos.permission.WRITE_IMAGEVIDEO 1412 * @param { Array<Album> } albums - Specify which albums to delete 1413 * @param { AsyncCallback<void> } callback - Returns void 1414 * @throws { BusinessError } 202 - Called by non-system application. 1415 * @throws { BusinessError } 401 - if parameter is invalid 1416 * @throws { BusinessError } 13900012 - Permission denied 1417 * @throws { BusinessError } 13900020 - Invalid argument 1418 * @throws { BusinessError } 14000011 - System inner fail 1419 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1420 * @systemapi 1421 * @since 10 1422 */ 1423 deleteAlbums(albums: Array<Album>, callback: AsyncCallback<void>): void; 1424 /** 1425 * Delete generic user-created albums. 1426 * 1427 * @permission ohos.permission.WRITE_IMAGEVIDEO 1428 * @param { Array<Album> } albums - Specify which albums to delete 1429 * @returns { Promise<void> } Returns the promise 1430 * @throws { BusinessError } 202 - Called by non-system application. 1431 * @throws { BusinessError } 401 - if parameter is invalid 1432 * @throws { BusinessError } 13900012 - Permission denied 1433 * @throws { BusinessError } 13900020 - Invalid argument 1434 * @throws { BusinessError } 14000011 - System inner fail 1435 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1436 * @systemapi 1437 * @since 10 1438 */ 1439 deleteAlbums(albums: Array<Album>): Promise<void>; 1440 /** 1441 * Fetch albums. 1442 * 1443 * @permission ohos.permission.READ_IMAGEVIDEO 1444 * @param { AlbumType } type - Album type. 1445 * @param { AlbumSubtype } subtype - Album subtype. 1446 * @param { FetchOptions } options - options to fetch albums 1447 * @param { AsyncCallback<FetchResult<Album>> } callback - Returns the fetch result 1448 * @throws { BusinessError } 401 - if type options is not FetchOption 1449 * @throws { BusinessError } 13900012 - Permission denied 1450 * @throws { BusinessError } 13900020 - Invalid argument 1451 * @throws { BusinessError } 14000011 - System inner fail 1452 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1453 * @since 10 1454 */ 1455 getAlbums( 1456 type: AlbumType, 1457 subtype: AlbumSubtype, 1458 options: FetchOptions, 1459 callback: AsyncCallback<FetchResult<Album>> 1460 ): void; 1461 /** 1462 * Fetch albums. 1463 * 1464 * @permission ohos.permission.READ_IMAGEVIDEO 1465 * @param { AlbumType } type - Album type. 1466 * @param { AlbumSubtype } subtype - Album subtype. 1467 * @param { AsyncCallback<FetchResult<Album>> } callback - Returns the fetch result 1468 * @throws { BusinessError } 401 - if type options is not FetchOption 1469 * @throws { BusinessError } 13900012 - Permission denied 1470 * @throws { BusinessError } 13900020 - Invalid argument 1471 * @throws { BusinessError } 14000011 - System inner fail 1472 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1473 * @since 10 1474 */ 1475 getAlbums(type: AlbumType, subtype: AlbumSubtype, callback: AsyncCallback<FetchResult<Album>>): void; 1476 /** 1477 * Fetch albums. 1478 * 1479 * @permission ohos.permission.READ_IMAGEVIDEO 1480 * @param { AlbumType } type - Album type. 1481 * @param { AlbumSubtype } subtype - Album subtype. 1482 * @param { FetchOptions } [options] - options to fetch albums 1483 * @returns { Promise<FetchResult<Album>> } - Returns the fetch result 1484 * @throws { BusinessError } 401 - if type options is not FetchOption 1485 * @throws { BusinessError } 13900012 - Permission denied 1486 * @throws { BusinessError } 13900020 - Invalid argument 1487 * @throws { BusinessError } 14000011 - System inner fail 1488 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1489 * @since 10 1490 */ 1491 getAlbums(type: AlbumType, subtype: AlbumSubtype, options?: FetchOptions): Promise<FetchResult<Album>>; 1492 /** 1493 * Delete assets 1494 * 1495 * @permission ohos.permission.WRITE_IMAGEVIDEO 1496 * @param { Array<string> } uriList - Uris of assets to delete 1497 * @param { AsyncCallback<void> } callback - No value returned 1498 * @throws { BusinessError } 202 - Called by non-system application. 1499 * @throws { BusinessError } 401 - if parameter is invalid 1500 * @throws { BusinessError } 13900012 - Permission denied 1501 * @throws { BusinessError } 13900020 - Invalid argument 1502 * @throws { BusinessError } 14000002 - Invalid uri 1503 * @throws { BusinessError } 14000011 - System inner fail 1504 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1505 * @systemapi 1506 * @since 10 1507 */ 1508 deleteAssets(uriList: Array<string>, callback: AsyncCallback<void>): void; 1509 /** 1510 * Delete assets 1511 * 1512 * @permission ohos.permission.WRITE_IMAGEVIDEO 1513 * @param { Array<string> } uriList - Uris of assets to delete 1514 * @returns { Promise<void> } - Returns void 1515 * @throws { BusinessError } 202 - Called by non-system application. 1516 * @throws { BusinessError } 401 - if parameter is invalid 1517 * @throws { BusinessError } 13900012 - Permission denied 1518 * @throws { BusinessError } 13900020 - Invalid argument 1519 * @throws { BusinessError } 14000002 - Invalid uri 1520 * @throws { BusinessError } 14000011 - System inner fail 1521 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1522 * @systemapi 1523 * @since 10 1524 */ 1525 deleteAssets(uriList: Array<string>): Promise<void>; 1526 /** 1527 * Register change notify for the specified uri. 1528 * 1529 * @param { string } uri - PhotoAsset's uri, album's uri or DefaultChangeUri 1530 * @param { boolean } forChildUris - Monitor the child uris. 1531 * @param { Callback<ChangeData> } callback - Returns the changed data 1532 * @throws { BusinessError } 401 - if parameter is invalid 1533 * @throws { BusinessError } 13900012 - Permission denied 1534 * @throws { BusinessError } 13900020 - Invalid argument 1535 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1536 * @since 10 1537 */ 1538 registerChange(uri: string, forChildUris: boolean, callback: Callback<ChangeData>): void; 1539 /** 1540 * Unregister change notify for the specified uri. 1541 * 1542 * @param { string } uri - PhotoAsset's uri, album's uri or DefaultChangeUri 1543 * @param { Callback<ChangeData> } [callback] - The callback function to unregister. 1544 * @throws { BusinessError } 401 - if parameter is invalid 1545 * @throws { BusinessError } 13900012 - Permission denied 1546 * @throws { BusinessError } 13900020 - Invalid argument 1547 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1548 * @since 10 1549 */ 1550 unRegisterChange(uri: string, callback?: Callback<ChangeData>): void; 1551 /** 1552 * Create a pop-up box to delete photos 1553 * 1554 * @permission ohos.permission.WRITE_IMAGEVIDEO 1555 * @param { Array<string> } uriList - List of the asset uris to be deleted 1556 * @param { AsyncCallback<void> } callback - Returns void 1557 * @throws { BusinessError } 401 - if parameter is invalid 1558 * @throws { BusinessError } 13900012 - Permission denied 1559 * @throws { BusinessError } 13900020 - Invalid argument 1560 * @throws { BusinessError } 14000011 - System inner fail 1561 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1562 * @since 10 1563 */ 1564 createDeleteRequest(uriList: Array<string>, callback: AsyncCallback<void>): void; 1565 /** 1566 * Create a pop-up box to delete photos 1567 * 1568 * @permission ohos.permission.WRITE_IMAGEVIDEO 1569 * @param { Array<string> } uriList - List of the asset uris to be deleted 1570 * @returns { Promise<void> } - Returns void 1571 * @throws { BusinessError } 401 - if parameter is invalid 1572 * @throws { BusinessError } 13900012 - Permission denied 1573 * @throws { BusinessError } 13900020 - Invalid argument 1574 * @throws { BusinessError } 14000011 - System inner fail 1575 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1576 * @since 10 1577 */ 1578 createDeleteRequest(uriList: Array<string>): Promise<void>; 1579 /** 1580 * Get the index of the asset in the album 1581 * 1582 * @permission ohos.permission.READ_IMAGEVIDEO 1583 * @param { string } photoUri - The photo asset uri. 1584 * @param { string } albumUri - The album uri. 1585 * @param { FetchOptions } options - fetch options 1586 * @param { AsyncCallback<number> } callback - Returns the index of the asset in the album 1587 * @throws { BusinessError } 202 - Called by non-system application. 1588 * @throws { BusinessError } 401 - if parameter is invalid 1589 * @throws { BusinessError } 13900012 - Permission denied 1590 * @throws { BusinessError } 13900020 - Invalid argument 1591 * @throws { BusinessError } 14000011 - System inner fail 1592 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1593 * @systemapi 1594 * @since 10 1595 */ 1596 getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions, callback: AsyncCallback<number>): void; 1597 /** 1598 * Get the index of the asset in the album 1599 * 1600 * @permission ohos.permission.READ_IMAGEVIDEO 1601 * @param { string } photoUri - The photo asset uri. 1602 * @param { string } albumUri - The album uri. 1603 * @param { FetchOptions } options - fetch options 1604 * @returns { Promise<number> } - Returns the index of the asset in the album 1605 * @throws { BusinessError } 202 - Called by non-system application. 1606 * @throws { BusinessError } 401 - if parameter is invalid 1607 * @throws { BusinessError } 13900012 - Permission denied 1608 * @throws { BusinessError } 13900020 - Invalid argument 1609 * @throws { BusinessError } 14000011 - System inner fail 1610 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1611 * @systemapi 1612 * @since 10 1613 */ 1614 getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions): Promise<number>; 1615 /** 1616 * Release PhotoAccessHelper instance 1617 * 1618 * @param { AsyncCallback<void> } callback - Returns void 1619 * @throws { BusinessError } 401 - if parameter is invalid 1620 * @throws { BusinessError } 13900020 - Invalid argument 1621 * @throws { BusinessError } 14000011 - System inner fail 1622 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1623 * @since 10 1624 */ 1625 release(callback: AsyncCallback<void>): void; 1626 /** 1627 * Release PhotoAccessHelper instance 1628 * 1629 * @returns { Promise<void> } Returns void 1630 * @throws { BusinessError } 401 - if parameter is invalid 1631 * @throws { BusinessError } 13900020 - Invalid argument 1632 * @throws { BusinessError } 14000011 - System inner fail 1633 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1634 * @since 10 1635 */ 1636 release(): Promise<void>; 1637 } 1638 1639 /** 1640 * Enumeration types of data change. 1641 * 1642 * @enum { number } NotifyType 1643 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1644 * @since 10 1645 */ 1646 enum NotifyType { 1647 /** 1648 * Data(assets or albums) have been newly created 1649 * 1650 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1651 * @since 10 1652 */ 1653 NOTIFY_ADD, 1654 /** 1655 * Data(assets or albums) have been modified 1656 * 1657 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1658 * @since 10 1659 */ 1660 NOTIFY_UPDATE, 1661 /** 1662 * Data(assets or albums) have been removed 1663 * 1664 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1665 * @since 10 1666 */ 1667 NOTIFY_REMOVE, 1668 /** 1669 * Assets have been added to an album. 1670 * 1671 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1672 * @since 10 1673 */ 1674 NOTIFY_ALBUM_ADD_ASSET, 1675 /** 1676 * Assets have been removed from an album. 1677 * 1678 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1679 * @since 10 1680 */ 1681 NOTIFY_ALBUM_REMOVE_ASSET 1682 } 1683 1684 /** 1685 * Enumeration uris for registerChange. 1686 * 1687 * @enum { string } DefaultChangeUri 1688 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1689 * @since 10 1690 */ 1691 enum DefaultChangeUri { 1692 /** 1693 * Uri for default PhotoAsset, use with forDescendant{true}, will receive all PhotoAsset's change notifications 1694 * 1695 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1696 * @since 10 1697 */ 1698 DEFAULT_PHOTO_URI = 'file://media/Photo', 1699 /** 1700 * Uri for default Album, use with forDescendant{true}, will receive all Album's change notifications 1701 * 1702 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1703 * @since 10 1704 */ 1705 DEFAULT_ALBUM_URI = 'file://media/PhotoAlbum' 1706 } 1707 1708 /** 1709 * Defines the change data 1710 * 1711 * @interface ChangeData 1712 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1713 * @since 10 1714 */ 1715 interface ChangeData { 1716 /** 1717 * The NotifyType of ChangeData 1718 * 1719 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1720 * @since 10 1721 */ 1722 type: NotifyType; 1723 /** 1724 * The changed uris 1725 * 1726 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1727 * @since 10 1728 */ 1729 uris: Array<string>; 1730 /** 1731 * Change details of the asset uris to an album. 1732 * 1733 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1734 * @since 10 1735 */ 1736 extraUris: Array<string>; 1737 } 1738 1739 /** 1740 * PhotoViewMIMETypes represents the type of media resource that photo picker selects. 1741 * 1742 * @enum { string } PhotoViewMIMETypes 1743 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1744 * @since 10 1745 */ 1746 export enum PhotoViewMIMETypes { 1747 /** 1748 * IMAGE_TYPE indicates that the selected media resources are images. 1749 * 1750 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1751 * @since 10 1752 */ 1753 IMAGE_TYPE = 'image/*', 1754 /** 1755 * VIDEO_TYPE indicates that the selected media resources are videos. 1756 * 1757 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1758 * @since 10 1759 */ 1760 VIDEO_TYPE = 'video/*', 1761 /** 1762 * IMAGE_VIDEO_TYPE indicates that the selected media resources are images and videos. 1763 * 1764 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1765 * @since 10 1766 */ 1767 IMAGE_VIDEO_TYPE = '*/*' 1768 } 1769 1770 /** 1771 * PhotoSelectOptions Object 1772 * 1773 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1774 * @since 10 1775 */ 1776 class PhotoSelectOptions { 1777 /** 1778 * The Type of the file in the picker window. 1779 * 1780 * @type { ?PhotoViewMIMETypes } 1781 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1782 * @since 10 1783 */ 1784 MIMEType?: PhotoViewMIMETypes; 1785 1786 /** 1787 * Maximum number of images for a single selection. 1788 * 1789 * @type { ?number } 1790 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1791 * @since 10 1792 */ 1793 maxSelectNumber?: number; 1794 } 1795 1796 /** 1797 * PhotoSelectResult Object 1798 * 1799 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1800 * @since 10 1801 */ 1802 class PhotoSelectResult { 1803 /** 1804 * The uris for the selected files. 1805 * 1806 * @type { Array<string> } 1807 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1808 * @since 10 1809 */ 1810 photoUris: Array<string>; 1811 1812 /** 1813 * Original option. 1814 * 1815 * @type { boolean } 1816 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1817 * @since 10 1818 */ 1819 isOriginalPhoto: boolean; 1820 } 1821 1822 /** 1823 * PhotoViewPicker Object 1824 * 1825 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1826 * @since 10 1827 */ 1828 class PhotoViewPicker { 1829 /** 1830 * Pull up the photo picker based on the selection mode. 1831 * 1832 * @param { PhotoSelectOptions } option - represents the options provided in select mode. 1833 * @returns { Promise<PhotoSelectResult> } Returns the uris for the selected files. 1834 * @throws { BusinessError } 401 - if parameter is invalid 1835 * @throws { BusinessError } 13900042 - Unknown error 1836 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1837 * @since 10 1838 */ 1839 select(option?: PhotoSelectOptions): Promise<PhotoSelectResult>; 1840 1841 /** 1842 * Pull up the photo picker based on the selection mode. 1843 * 1844 * @param { PhotoSelectOptions } option - represents the options provided in select mode. 1845 * @param { AsyncCallback<PhotoSelectResult> } callback - callback 1846 * @throws { BusinessError } 401 - if parameter is invalid 1847 * @throws { BusinessError } 13900042 - Unknown error 1848 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1849 * @since 10 1850 */ 1851 select(option: PhotoSelectOptions, callback: AsyncCallback<PhotoSelectResult>): void; 1852 1853 /** 1854 * Pull up the photo picker based on the selection mode. 1855 * 1856 * @param { AsyncCallback<PhotoSelectResult> } callback - callback 1857 * @throws { BusinessError } 401 - if parameter is invalid 1858 * @throws { BusinessError } 13900042 - Unknown error 1859 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 1860 * @since 10 1861 */ 1862 select(callback: AsyncCallback<PhotoSelectResult>): void; 1863 } 1864} 1865 1866export default photoAccessHelper; 1867