예제 #1
0
 public TempUploadStorage(DiskUploadStorageOptions options)
     : base(options)
 {
     if (!Directory.Exists(RootPath))
     {
         Directory.CreateDirectory(RootPath);
         File.WriteAllText(Path.Combine(RootPath, ".temporary"), "");
     }
 }
예제 #2
0
 public TempUploadStorage(DiskUploadStorageOptions options)
     : base(options)
 {
     if (!Directory.Exists(RootPath))
     {
         try
         {
             Directory.CreateDirectory(RootPath);
             File.WriteAllText(Path.Combine(RootPath, ".temporary"), "");
         }
         catch
         {
             // swallow exception as this causes startup errors
             // and application pool crashes if upload folder
             // can't be accessed, better to ignore
         }
     }
 }
예제 #3
0
        public DiskUploadStorage(DiskUploadStorageOptions options)
        {
            var opt = options ?? throw new ArgumentNullException(nameof(options));

            if (string.IsNullOrWhiteSpace(opt.RootPath))
            {
                throw new ArgumentNullException(nameof(opt.RootPath));
            }

            if (string.IsNullOrWhiteSpace(opt.RootUrl))
            {
                throw new ArgumentNullException(nameof(opt.RootUrl));
            }

            RootUrl  = opt.RootUrl;
            RootPath = opt.RootPath;

            if (!Path.IsPathRooted(RootPath))
            {
                RootPath = Path.Combine(AppContext.BaseDirectory, PathHelper.ToPath(RootPath));
            }
        }