目录

File Structure

App Resources

An app contains the manifest.json file that describes the project configurations, the app.ux file that records the common resources of the project, and multiple UX files, each of which describes a page or custom elements. A typical example is as follows:

App directory

|—— manifest.json

|—— app.ux

|—— Page1

| |—— page1.ux

|—— Page2

| |—— page2.ux

|—— Common

|—— ComponentA.ux

|—— ComponentB.ux

|—— xxx.png

Common resource files and element files are stored in the Common directory. Resource files and element files (for example, image, CSS, and JS files) dedicated to a page are stored in the directory of that page.

All file names in a project can contain only letters, digits, periods (.), underscores (_), hyphens (-), and parentheses (()) but cannot contain double dot (..) or dot-slash (./). Each file name can contain at most 300 characters.

File Storage

On app platforms, files are stored by partition. Currently, the following partitions are supported:

Data processed by the quick app APIs may be read by other apps when being used on a PC. Therefore, you are not advised to store sensitive data.

URI

URIs are used to identify app resources and files, and elements and APIs access app resources and files based on URIs.

Resource Type

URI

Read-Only

Example

Description

App resources

/path

Yes

/Common/header.png

-

Cache

internal://cache/path/

No

internal://cache/fetch-123456.png

Content directory of Huawei Quick App Engine, which can be accessed by users.

Files

internal://files/path

No

internal://files/image/demo.png

Content directory of Huawei Quick App Engine, which can be accessed by users.

Mass

internal://mass/path

No

internal://mass/video/demo.mp4

External directory, which can be accessed by users.

You can access the /Android/data/com.huawei.fastapp.dev/files/fastappEngine/ directory through the file manager and then access this external directory.

Temp

internal://tmp/path

Yes

internal://tmp/xxxxx/demo.png (file name)

The URI is automatically generated by the system.

The regular expression [^\\s\"':|*?<>\\\\]+ can be used to verify the URI enclosed in quotation marks. A URI cannot contain a double dot (..). A URI supports the directory structure where directories are separated by slashes (/). An internal URI indicates a file dedicated to an app. The app ID does not need to be specified in an internal URI. Internal URIs dedicated to different apps point to different files even when they are the same.

Resource and File Access Rules

App resource paths are classified into absolute paths and relative paths. A path starting with a slash (/), for example, /Common/a.png, is an absolute path. A path not starting with a slash (/), for example, a.png or ../Common/a.png is a relative path.

App resource files are classified into code files and resource files. Code files are files that contain code, such as JS, CSS, and UX files. Other files are resource files such as image and video files.

  1. To import a code file, use its relative path, for example, ../Common/component.ux.
  2. To reference a resource file (for example, an image file or a video file), use its relative path, for example, ./abc.png.
  3. To reference a resource file in a code file imported to another code file, use a relative path of the resource file if the two code files are in the same directory, and use an absolute path if they are in different directories. That is because the path will be copied to the target file when the imported file is compiled, and the directory will change after the compilation is complete.

For example, the a.css file is imported to the b.ux file. If they are in the same directory, use a relative path of a resource file, for example, abc.png, to reference this resource file in the a.css file; if they are in different directories, use an absolute path, for example, /Common/abc.png.

For example, the a.ux file is imported to the b.ux file. If they are in the same directory, use a relative path, for example, a.png, to reference this resource file in the a.ux file; if they are in different directories, use an absolute path, for example, /Common/abc.png.

Same as frontend development, you can use the url(Path) method to access a resource file in a CSS file. For example, use url(/Common/abc.png) to access the abc.png file.