コード例 #1
0
        public ActionResult <string> Post(string version, string type, [FromBody] APIDownloadRequestViewModel model)
        {
            if (type.ToLower() != "video" && type.ToLower() != "audio")
            {
                return(InvalidType());
            }

            if (version == "v1.0")
            {
                return(Version1(type, model));
            }
            else
            {
                return(StatusCode(StatusCodes.Status400BadRequest, "Wrong or Deprecated API Version."));
            }
        }
コード例 #2
0
        private ActionResult <string> Version1(string type, APIDownloadRequestViewModel model)
        {
            bool isVideo = type.ToLower() == "video";

            try
            {
                string filePath;
                string status;

                bool success = dlHandler.Download(isVideo, model.DownloadURL, model.CallSource, out filePath, out status);

                string responseURL = $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}{filePath}"; // current domain + relative path.
                return(new JsonResult(new Data.DownloadResponse(success, responseURL, status)));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }