Example #1
0
    private async Task ReserveUploadAsync(UploadLinkModel model)
    {
        CancellationToken cancellationToken = this.HttpContext.RequestAborted;
        StoredMetadata    metadata          = new StoredMetadata {
            Expiration    = model.Expiration,
            UploadedOn    = DateTime.UtcNow,
            IsReservation = true,
            Sender        = model.Sender
        };

        // Ensure no empty contact information
        if (model.Sender != null && String.IsNullOrEmpty(model.Sender.Name) && String.IsNullOrEmpty(model.Sender.EmailAddress))
        {
            metadata.Sender = null;
        }

        // Write away
        using (Stream fileStream = this._fileWriter.OpenWriteStream(this._fileStore.GetMetadataFile(model.FileIdentifier))) {
            using (StreamWriter sw = new StreamWriter(fileStream, Encoding.UTF8)) {
                await sw.WriteAsync(metadata.Serialize()).ConfigureAwait(false);

                await fileStream.FlushAsync(cancellationToken).ConfigureAwait(false);
            }
        }
    }
Example #2
0
    public async Task <IActionResult> Index(IFormCollection form)
    {
        UploadLinkModel model = UploadModelFactory.CreateLink();

        if (!await this.TryUpdateModelAsync(model))
        {
            return(this.View(model));
        }

        await this.ReserveUploadAsync(model);

        return(this.View("LinkCreated", model));
    }
Example #3
0
    public IActionResult Index()
    {
        UploadLinkModel model = UploadModelFactory.CreateLink();

        return(this.View(model));
    }