Exemple #1
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "api/upload")] HttpRequest req,
            ILogger log)
        {
            string  requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data        = JsonConvert.DeserializeObject(requestBody);
            string  id          = data?.id;

            if (await _service.FindAsync(id) != null)
            {
                return(new ConflictObjectResult(new { }));
            }

            var media = await _service.AddAsync(id);

            return(new CreatedResult($"/api/medias/{Uri.EscapeUriString(id)}", new { media.DeleteToken }));
        }