コード例 #1
0
        public static async Task <IActionResult> GetFile([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "GetFile/{contentid}/{filename}")] HttpRequest req, string contentid, string filename, ILogger log)
        {
            string ClientIP = req.HttpContext.Connection.RemoteIpAddress.ToString();

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

            customerid = customerid ?? "";
            string shortname = req.Query["shortname"];

            shortname = shortname ?? "";
            //string contentid = req.Query["contentid"];
            //contentid = contentid ?? "";
            //string filename = req.Query["filename"];
            //filename = filename ?? "";

            if (!Base.ValidateIP(ClientIP))
            {
                if (Environment.GetEnvironmentVariable("EnforceGetURL") == "true")
                {
                    return(new NotFoundResult());
                }
            }
            else
            {
            }

            string sPath = Path.Combine(contentid, filename);

            if (!string.IsNullOrEmpty(shortname))
            {
                sPath = Path.Combine("proxy", shortname, contentid, filename);
            }

            Base.WriteLog($"GetFile {sPath}", ClientIP, 1200, customerid);
            log.LogInformation($"GetFile: {sPath} CustomerID: {customerid}");

            return(await Base.GetFile(sPath, customerid));
        }