コード例 #1
0
        //[Route("/api/download/{id}")]
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post")] WebhookResponse webhookResponse,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");



            if (_downloadService == null)
            {
                log.LogError("download service null");
                return(new BadRequestObjectResult("error"));
            }
            if (webhookResponse.transcript_id is null || webhookResponse.status != "completed")
            {
                return(new BadRequestObjectResult("errors galore!!"));
            }

            DownloadResponse downloadResponse;

            try
            {
                downloadResponse = await _downloadService.FetchDownload(webhookResponse.transcript_id);
            }
            catch (Exception e)
            {
                log.LogError($"Error from download service:{e}");
                return(new BadRequestObjectResult(e));
            }

            return(new JsonResult(downloadResponse));
        }
コード例 #2
0
        //[Route("/api/download/{id}")]
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get")] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            string id = req.Query["id"];

            if (String.IsNullOrEmpty(id))
            {
                return(new BadRequestObjectResult("Please pass a id on the query string"));
            }


            if (_downloadService == null)
            {
                log.LogError("download service null");
                return(new BadRequestObjectResult("error"));
            }

            DownloadResponse downloadResponse;

            try
            {
                downloadResponse = await _downloadService.FetchDownload(id);
            }
            catch (Exception e)
            {
                log.LogError($"f**k it:{e}");
                return(new BadRequestObjectResult(e));
            }

            return(downloadResponse.GeneralStatusEnum == GeneralStatusEnum.Ok
                ? new OkObjectResult(downloadResponse.ImageEntity.ProcessedUrl)
                : new ObjectResult(StatusCodes.Status102Processing));
        }