public TempUploadStorage(DiskUploadStorageOptions options) : base(options) { if (!Directory.Exists(RootPath)) { Directory.CreateDirectory(RootPath); File.WriteAllText(Path.Combine(RootPath, ".temporary"), ""); } }
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 } } }
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)); } }