Esempio n. 1
0
        public async Task <IHttpActionResult> ConvertAsync(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                var error = new { errorCode = 402, errorMsg = "id should not empty" };
                return(Ok(error));
            }

            //get the file downloader
            byte[] armFileData = await _fileDownloaderService.DownloadWxFileAsync(id);

            string absAmrFilePath = await _fileDownloaderService.SaveFileAsync(_hostingEnvironmentService.AppMapPath("~/uploads/"), armFileData);

            //get the converter
            string absMp3FilePath = await _audioFileService.ConvertAmr2Mp3Async(absAmrFilePath);

            //return the access path to user
            string relFilePath = absMp3FilePath.Replace(_hostingEnvironmentService.AppPhysicalPath(), string.Empty);

            if (relFilePath.StartsWith("\\") == false)
            {
                relFilePath = "\\" + relFilePath;
            }
            relFilePath = relFilePath.Replace("\\", "/");
            return(Ok(relFilePath));
        }