Configure File Metadata¶
Overview¶
You can configure a file’s metadata attributes from the Stitch UI or by importing an application directory that includes a metadata configuration file. Select the tab below that corresponds to the method you want to use.
Note
If you do not specify a Content-Type
attribute for a file, Stitch
will attempt to automatically add a Content-Type
attribute to it
based on the file extension.
For example, Stitch would automatically add the attribute
Content-Type: application/html
to the file myPage.html
.
Procedure¶
- Stitch UI
- Import/Export
Add a New Attribute¶
Once you have found the file, you need to add a new metadata attribute to it. To add a new metadata attribute:
- Click the file’s Actions (…) button.
- Click Edit Attributes…
- In the Set Attributes modal, click Add Attribute.
Select the Attribute Type and Value¶
The new metadata attribute will not have a type or value when you first add it.
- Select the attribute type from new attribute’s left-hand dropdown
- Enter a value for the attribute in the right-hand input box.
- Click Save.
Export Your Stitch Application¶
To add metadata attributes to hosted files with stitch-cli you need to export an application directory for your application.
You can export your application from the Export tab of the Settings page in the Stitch UI, or by running the following command from an authenticated instance of stitch-cli:
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.
Stitch 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:
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:
|
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: