internal ExpirationHelper(DefaultTusConfiguration configuration) { _expirationStore = configuration.Store as ITusExpirationStore; _expiration = configuration.Expiration; _isSupported = _expirationStore != null && _expiration != null; _getSystemTime = configuration.GetSystemTime; }
public ExpiredFilesCleanupJob(FileUploadService fileUploadService, ILogger <ExpiredFilesCleanupJob> logger) { _logger = logger; DefaultTusConfiguration config = fileUploadService.CreateTusConfiguration(); _expirationStore = (ITusExpirationStore)config.Store; _expiration = config.Expiration; }
internal override async Task <bool> Handle(ContextAdapter context) { var metadata = context.Request.GetHeader(HeaderConstants.UploadMetadata); string fileId; DateTimeOffset?expires = null; var response = context.Response; var request = context.Request; var cancellationToken = context.CancellationToken; var tusConcatenationStore = context.Configuration.Store as ITusConcatenationStore; var uploadConcat = request.Headers.ContainsKey(HeaderConstants.UploadConcat) ? new UploadConcat(request.GetHeader(HeaderConstants.UploadConcat), context.Configuration.UrlPath) : null; var supportsUploadConcat = tusConcatenationStore != null && uploadConcat != null; var uploadLength = GetUploadLength(context.Request); if (await HandleOnBeforeCreateAsync(context, supportsUploadConcat, uploadConcat, metadata, uploadLength)) { return(true); } if (supportsUploadConcat) { fileId = await HandleCreationOfConcatFiles(context, uploadConcat, tusConcatenationStore, uploadLength, metadata, cancellationToken); } else { var creationStore = (ITusCreationStore)context.Configuration.Store; fileId = await creationStore.CreateFileAsync(uploadLength, metadata, cancellationToken); await HandleOnCreateComplete(context, fileId, supportsUploadConcat, uploadConcat, metadata, uploadLength); } ITusExpirationStore expirationStore = context.Configuration.Store as ITusExpirationStore; if (expirationStore != null && context.Configuration.Expiration != null && !(uploadConcat?.Type is FileConcatFinal)) { expires = DateTimeOffset.UtcNow.Add(context.Configuration.Expiration.Timeout); await expirationStore.SetExpirationAsync(fileId, expires.Value, context.CancellationToken); } response.SetHeader(HeaderConstants.TusResumable, HeaderConstants.TusResumableValue); response.SetHeader(HeaderConstants.Location, $"{context.Configuration.UrlPath.TrimEnd('/')}/{fileId}"); if (expires != null) { response.SetHeader(HeaderConstants.UploadExpires, expires.Value.ToString("R")); } response.SetStatus((int)HttpStatusCode.Created); return(true); }
private async Task ValidateInternal(ContextAdapter context, ITusExpirationStore expirationStore) { var expires = await expirationStore.GetExpirationAsync(context.Request.FileId, context.CancellationToken); if (expires?.HasPassed() == true) { await NotFound(); } }
public ExpiredFilesCleanupService( IApplicationLifetime applicationLifetime, DefaultTusConfiguration tusConfiguration, ILoggerFactory loggerFactory) { _applicationLifetime = applicationLifetime; _expirationStore = (ITusExpirationStore)tusConfiguration.Store; _expiration = tusConfiguration.Expiration; _logger = loggerFactory.CreateLogger <ExpiredFilesCleanupService>(); }
public ExpiredFilesCleanupService(ILogger <ExpiredFilesCleanupService> logger, DefaultTusConfiguration config) { _logger = logger; _expirationStore = (ITusExpirationStore)config.Store; _expiration = config.Expiration; }
public AssetCleanupGrain(ITusExpirationStore expirationStore) { this.expirationStore = expirationStore; }