Configure File Metadata
Overview
You can configure a file's metadata attributes to describe aspects of the file, such as its content type, language, or encoding. You can also use metadata attributes to configure the CDN's caching behavior and specify how clients should handle files when they access them.
Note
If you do not specify a Content-Type
metadata attribute for a hosted
file, Atlas App Services will attempt to automatically add a Content-Type
attribute to it based on the file extension.
For example, App Services would automatically add the attribute
Content-Type: application/html
to the file myPage.html
.
Procedure
Add Attributes to the Metadata Configuration File
The metadata for all hosted files associated with your application is
configured by an array of metadata attribute definition objects that
you define in a file named metadata.json in your application's hosting
subdirectory.
Atlas App Services will automatically infer and assign a Content-Type
to every
file you upload. If you you want to override the default
Content-Type
or specify additional metadata attributes for a file, add an entry to
metadata.json for the file and
attributes that you want to configure. Each file's entry should be a
document with the following form:
[ { "path": "<File Resource Path>", "attrs": [ ..., <Attribute Definition> ], }, ... ]
Field | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
path | Required. The resource path of the
file. | ||||||||||
attrs | Required. An array of documents where each document represents a single metadata attribute. Attribute documents have the following form: Metadata Attribute Document
|
Note
If you include an entry in metadata.json
for a file that does
not exist, you will not be able to import your changes. Ensure that
only hosted files are represented in metadata.json
.
Import the File Metadata Configuration
Once you have added all the metadata attributes you want to configure
to metadata.json
, you can import the application directory to
actually update the associated file metadata.
Navigate to the root of the application directory and run the following command:
appservices push --include-hosting