You can add an extension for Egnyte in your stack that allows you to fetch the files stored in your Egnyte account and display them into a field in your Content Type. Subsequently, while creating entries, content managers can select one or more files as input value for the field.
This step-by-step guide explains how to create an Egnyte custom field extension for your content types in Contentstack. The steps performed are as follows:
- Register your app in Egnyte
- Add the ‘Egnyte’ custom field extension to your stack
- Use the extension
Step 1 - Register your app in Egnyte
In order to use this extension, you will first need to register for a developer account and create an app in Egnyte and generate app-specific credentials that are needed for authentication.
To do so, perform the steps given below:
- Log in to Egnyte’s developer site with an administrative developer account.
- Click on APPLICATIONS and select CREATE A NEW APPLICATION.
- Provide the following details for your app:
- Under Name of your application, enter a suitable title for your app.
- Set the Type to Publicly Available Application.
- Under Current User Base select New App.
- Set the Platform to Other.
- Under Egnyte domain you will use for testing, enter your Egnyte subdomain. This is the hosting URL of your app. For example, https://myCompany.egnyte.com/.
- Download the redirect.html file from the code folder and upload this file as an asset into your Contentstack stack. Retrieve the download link of this file. Enter this URL in Registered OAuth Redirect URI. We will use this redirect URI in Step 3.
Note: Refer Step 2 for the source code along with the redirect.html file of this extension.
- Click on REGISTER APPLICATION.
This registers your app and returns a success message with the created information. Note the Egnyte REST API Key value of your app as you will need it in Step 3.
Note: After creating your application, you need to wait for an approval from Egnyte before you can use the API key to generate your access token.
Step 2 - Add the ‘Egnyte’ custom field extension to your stack
- Go to Settings > Extensions. Click on the ‘+ Add Extension’ button on the top-right corner and select ‘Create new’.
- Select the Extension type as Custom Field.
On the configuration page, enter details in the fields as given below:
- Title: Provide a suitable title. For example, ‘Egnyte’.
- Field Data Type: Select the data type in which the input data of the field should be saved in Contentstack. Select ‘JSON’ in this case.
- Multiple: Leave this checkbox unchecked.
- Hosting Method: Select ‘Hosted By Contentstack’. As soon as you do this, you will see the ‘Extension Source Code’ field below.
- Extension Source Code: Enter the source code for the custom field. You can find the source code for the Egnyte extension here.
Config Parameter: Enter the Egnyte library name under folder. Then add the Egnyte Client Id (i.e., you Egnyte REST API key) as well as redirect URI that we retrieved in Step 1. Finally, enter your Egnyte account domain:
In the above code, for the folder parameter, pass the path where the JSON dump is stored on your file system.
For more details on your Egnyte API Key, refer the Request an API Key section.
- Click on Save. This will create your custom field.
Now, let’s understand how you can start using this custom field in your content type.
Step 3 - Use the extension
To use your custom field, you need to follow the steps given below:
- Create a content type by clicking on the ‘+ New Content Type’. Enter the required details for the content type and click on ‘Create and Add fields’.
This takes you to the ‘Content Type Builder’ page where you can add the required fields.
- Add the Custom field to your content type.
Select Egnyte from the dropdown and set the other properties of your custom field.
Note: You can provide specific instance-level configuration settings for your Custom Field extension. Learn more.
- After adding other relevant fields in your Content Type, click on Save and Close.
This will create your Content Type. Now you can use the custom field while creating an entry for this Content Type as shown below: