public async getFileContent()

in src/appservice-rest/Kudu/azure-app-kudu-service.ts [416:443]


    public async getFileContent(physicalPath: string, fileName: string): Promise<string> {
        physicalPath = physicalPath.replace(/[\\]/g, "/");
        physicalPath = physicalPath[0] == "/" ? physicalPath.slice(1): physicalPath;
        var httpRequest: WebRequest = {
            method: 'GET',
            uri: this._client.getRequestUri(`/api/vfs/${physicalPath}/${fileName}`),
            headers: {
                'If-Match': '*'
            }
        };

        try {
            var response = await this._client.beginRequest(httpRequest);
            core.debug(`getFileContent. Status code: ${response.statusCode} - ${response.statusMessage}`);
            if([200, 201, 204].indexOf(response.statusCode) != -1) {
                return response.body;
            }
            else if(response.statusCode === 404) {
                return null;
            }
            else {
                throw response;
            }
        }
        catch(error) {
            throw Error("Failed to get file content " + physicalPath + fileName + " from Kudu.\n" + this._getFormattedError(error));
        }
    }