protected override void DoJob() { foreach (var file in directoryFiles) { var filePath = file.Substring(mappedPath.TrimEnd('/').Length); StaticUploader.UploadFileAsync(Path.Combine(relativePath, filePath), file, (res) => StepDone()).Wait(); } }
public void Deconstruct(out TenantManager tenantManager, out StaticUploader staticUploader, out SecurityContext securityContext, out SettingsManager settingsManager, out StorageSettingsHelper storageSettingsHelper) { tenantManager = TenantManager; staticUploader = StaticUploader; securityContext = SecurityContext; settingsManager = SettingsManager; storageSettingsHelper = StorageSettingsHelper; }
protected override async Task DoJobAsync() { var tasks = new List <Task>(); foreach (var file in directoryFiles) { var filePath = file.Substring(mappedPath.TrimEnd('/').Length); tasks.Add(StaticUploader.UploadFileAsync(Path.Combine(relativePath, filePath), file, (res) => StepDone())); } await Task.WhenAll(tasks); }
public StaticUploaderScope(TenantManager tenantManager, StaticUploader staticUploader, SecurityContext securityContext, SettingsManager settingsManager, StorageSettingsHelper storageSettingsHelper) { TenantManager = tenantManager; StaticUploader = staticUploader; SecurityContext = securityContext; SettingsManager = settingsManager; StorageSettingsHelper = storageSettingsHelper; }
public WebPath( WebPathSettings webPathSettings, StaticUploader staticUploader, SettingsManager settingsManager, StorageSettingsHelper storageSettingsHelper, IHttpContextAccessor httpContextAccessor, IHostEnvironment hostEnvironment, CoreBaseSettings coreBaseSettings, IOptionsMonitor <ILog> options) : this(webPathSettings, staticUploader, settingsManager, storageSettingsHelper, hostEnvironment, coreBaseSettings, options) { HttpContextAccessor = httpContextAccessor; }
public UploadOperationProgress(StaticUploader staticUploader, string relativePath, string mappedPath) { StaticUploader = staticUploader; this.relativePath = relativePath; this.mappedPath = mappedPath; var extensions = ".png|.jpeg|.jpg|.gif|.ico|.swf|.mp3|.ogg|.eot|.svg|.ttf|.woff|.woff2|.css|.less|.js"; var extensionsArray = extensions.Split('|'); directoryFiles = Directory.GetFiles(mappedPath, "*", SearchOption.AllDirectories) .Where(r => extensionsArray.Contains(Path.GetExtension(r))) .ToList(); StepCount = directoryFiles.Count(); }
public WebPath( WebPathSettings webPathSettings, StaticUploader staticUploader, SettingsManager settingsManager, StorageSettingsHelper storageSettingsHelper, IHostEnvironment hostEnvironment, CoreBaseSettings coreBaseSettings, IOptionsMonitor <ILog> options) { WebPathSettings = webPathSettings; StaticUploader = staticUploader; SettingsManager = settingsManager; StorageSettingsHelper = storageSettingsHelper; HostEnvironment = hostEnvironment; CoreBaseSettings = coreBaseSettings; Options = options; }
public string GetPath(string relativePath) { if (!string.IsNullOrEmpty(relativePath) && relativePath.IndexOf('~') == 0) { throw new ArgumentException(string.Format("bad path format {0} remove '~'", relativePath), "relativePath"); } if (CoreBaseSettings.Standalone && StaticUploader.CanUpload()) { try { var result = StorageSettingsHelper.DataStore(SettingsManager.Load <CdnStorageSettings>()).GetInternalUri("", relativePath, TimeSpan.Zero, null).AbsoluteUri.ToLower(); if (!string.IsNullOrEmpty(result)) { return(result); } } catch (Exception) { } } return(WebPathSettings.GetPath(HttpContextAccessor.HttpContext, Options, relativePath)); }
public static string GetPath(string relativePath) { if (relativePath.StartsWith("~")) { throw new ArgumentException(string.Format("bad path format {0} remove '~'", relativePath), "relativePath"); } var result = relativePath; var ext = Path.GetExtension(relativePath).ToLowerInvariant(); if (CoreContext.Configuration.Standalone && StaticUploader.CanUpload()) { try { result = CdnStorageSettings.Load().DataStore.GetInternalUri("", relativePath, TimeSpan.Zero, null).AbsoluteUri.ToLower(); if (!string.IsNullOrEmpty(result)) { return(result); } } catch (Exception) { } } if (Appenders.Any()) { var avaliableAppenders = Appenders.Where(x => x.Extensions.Split('|').Contains(ext) || String.IsNullOrEmpty(ext)).ToList(); var avaliableAppendersCount = avaliableAppenders.LongCount(); AppenderConfigurationElement appender; if (avaliableAppendersCount > 1) { appender = avaliableAppenders[(int)(relativePath.Length % avaliableAppendersCount)]; } else if (avaliableAppendersCount == 1) { appender = avaliableAppenders.First(); } else { appender = Appenders.First(); } if (appender.Append.StartsWith("~")) { var query = string.Empty; //Rel path if (relativePath.IndexOfAny(new[] { '?', '=', '&' }) != -1) { //Cut it query = relativePath.Substring(relativePath.IndexOf('?')); relativePath = relativePath.Substring(0, relativePath.IndexOf('?')); } if (HostingEnvironment.IsHosted) { result = VirtualPathUtility.ToAbsolute(string.Format("{0}/{1}{2}", appender.Append.TrimEnd('/'), relativePath.TrimStart('/'), query)); } else { result = string.Format("{0}/{1}{2}", appender.Append.TrimEnd('/').TrimStart('~'), relativePath.TrimStart('/'), query); } } else { if (HostingEnvironment.IsHosted && SecureHelper.IsSecure() && !string.IsNullOrEmpty(appender.AppendSecure)) { result = string.Format("{0}/{1}", appender.AppendSecure.TrimEnd('/'), relativePath.TrimStart('/')); } else { //Append directly result = string.Format("{0}/{1}", appender.Append.TrimEnd('/'), relativePath.TrimStart('/')); } } } //To LOWER! cause Amazon is CASE SENSITIVE! return(result.ToLowerInvariant()); }