Skip to content

Interface and Operations / File Service

The File Service can expose a specified directory under "File Management" as static files, accessible by browsers or other systems.

1. Creating and Accessing

Add a file service under "Manage / File Services", specifying an ID and a root directory. The root directory is relative to the resource root directory in file management, must already exist, and cannot use .. to refer to a parent directory.

For example, with ID demo-web and root directory demo/web, where index.html exists, after adding index.html in [Index File], the access URLs are as follows:

Text Only
1
2
https://func.example.com/fs/demo-web/
https://func.example.com/fs/demo-web/index.html

Access paths are case-sensitive; access using the actual case of the File Service ID and file names.

The root directory should contain only files intended for public access; do not place configuration, secrets, private uploads, or script caches in it. Disabling the directory listing only hides the file list; known file URLs remain accessible.

2. Static Site Configuration

Added in version 8.1.20

Option Default Value Description
Auto Index Off Added in version 8.1.20; shows directory listing when no index page is found; also off by default if not set, including existing services
Index File Not set Added in version 8.1.20; searches in each requested directory in order; only file names are entered; since version 8.1.21, no index lookup is performed by default, and clearing all options also means no index lookup
Cache Duration Off Added in version 8.1.21, replacing the previous cache policy; when enabled, enter a non-negative integer number of seconds; 0 means no caching
Single-Page App Fallback Off Added in version 8.1.20; for non-existent paths without an extension, returns the root index page on GET / HEAD requests that explicitly accept text/html
404 Error Page Not set Added in version 8.1.20; enter a path relative to the service root; preserves the original status code, uses default error response when file is missing; since version 8.1.21, custom 403 error pages are no longer supported
Response Headers Not set Added in version 8.1.20; since version 8.1.21, enter one header-name: value per line; used for service responses and OPTIONS preflight; header names must not duplicate even with different casing

Directory requests look up the index file, then attempt auto-indexing; if neither is available, return 403. Directory URLs missing a trailing / are redirected to add it, preserving query parameters; files that do not exist typically return 404.

After upgrading to 8.1.21, verify the index file, cache, and error page settings of existing services; old configurations that do not comply with the new rules are treated as not configured.

File transfer supports HEAD, ETag / Last-Modified conditional requests, byte ranges, and file type detection. Custom response headers cannot override transport and message framing fields, nor Content-Range, Accept-Ranges, ETag, Last-Modified, Content-Encoding, Location, and Set-Cookie.

3. Cache and Response Headers

When [Cache Duration] is off or 0, responses use Cache-Control: no-store; when enabled with a positive integer number of seconds, successful content responses use Cache-Control: public, max-age=N. The interface provides common duration options and a response header preview. Long caching may delay users from seeing updated content; when publishing a static site, manage cache in conjunction with resource file names.

Service response headers override ordinary custom response headers in "System Settings"; when global custom response headers are enabled, system fixed response headers then override service headers with the same name. Cache response headers are uniformly controlled by [Cache Duration]; conflicting custom cache headers are removed, and Vary is preserved. Redirect, OPTIONS, and error responses use Cache-Control: no-store before response headers are sent.

Service response headers can configure CORS, allowing methods GET, HEAD, and OPTIONS. After explicitly specifying Access-Control-Allow-Origin, unrelated global credential policies are not automatically inherited; when credentials are required, explicitly set Access-Control-Allow-Credentials and avoid combining credentials with wildcard origin *.

Global response header restrictions and global CORS rules are described in Interface and Operations / System Settings.

4. SPA Routing

When using History routing, enable [Single-Page App Fallback], add an available root directory index page in [Index File], and set both the front-end route and resource base path to /fs/<File Service ID>/.

For example, /fs/demo-web/users/123 can return the root index page; missing static resources such as app.js still return 404, and existing directories do not use SPA fallback. Hash routing does not require enabling SPA fallback.

5. Deactivation and Deletion

After deactivation, the service address can no longer serve files; it resumes after re-enabling. Deletion only removes the service configuration, not the resource files, and the original public address becomes invalid.

After modifying the root directory or configuration, check the index page, direct file links, non-existent paths, and the directory listing, cache, and CORS behavior affected by this modification.