public async uploadFile()

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


    public async uploadFile(physicalPath: string, fileName: string, filePath: string): Promise<void> {
        physicalPath = physicalPath.replace(/[\\]/g, "/");
        physicalPath = physicalPath[0] == "/" ? physicalPath.slice(1): physicalPath;
        if(!await exists(filePath)) {
            throw new Error('FilePathInvalid' + filePath);
        }

        var httpRequest: WebRequest = {
            method: 'PUT',
            uri: this._client.getRequestUri(`/api/vfs/${physicalPath}/${fileName}`),
            headers: {
                'If-Match': '*'
            },
            body: fs.createReadStream(filePath)
        };

        try {
            var response = await this._client.beginRequest(httpRequest);
            core.debug(`uploadFile. Data: ${JSON.stringify(response)}`);
            if([200, 201, 204].indexOf(response.statusCode) != -1) {
                return response.body;
            }

            throw response;
        }
        catch(error) {
            throw Error("Failed to upload file " + physicalPath + fileName + " from Kudu.\n" + this._getFormattedError(error));;
        }
    }