Exemplo n.º 1
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));
    }
Exemplo n.º 2
0
    public async Task <IActionResult> UploadFileHandler(FileIdentifier id)
    {
        var file = await this._uploadedFileRepository.GetFileReservation(id);

        if (file == null)
        {
            this.Response.StatusCode = 404 /* Not Found */;
            return(this.View("UploadLinkExpired"));
        }

        // Set-up authentication
        ClaimsIdentity userIdentity = new ClaimsIdentity(KnownAuthenticationScheme.PassphraseScheme);

        userIdentity.AddClaims(new[] {
            new Claim(ClaimTypes.Name, KnownPolicies.Upload, ClaimValueTypes.String, "https://ifs"),
            new Claim(KnownClaims.RestrictionId, id.ToString(), ClaimValueTypes.String, "https://ifs"),
        });

        ClaimsPrincipal userPrincipal = new ClaimsPrincipal(userIdentity);

        AuthenticationProperties authenticationOptions = new AuthenticationProperties {
            AllowRefresh = true,
            ExpiresUtc   = DateTimeOffset.UtcNow.AddMinutes(30),
            IsPersistent = false
        };

        await this.HttpContext.SignInAsync(KnownAuthenticationScheme.PassphraseScheme, userPrincipal, authenticationOptions);

        // Create model for upload
        UploadModel uploadModel = UploadModelFactory.Create();

        uploadModel.FileIdentifier = file.Id;
        uploadModel.Expiration     = file.Metadata.Expiration;
        uploadModel.IsReservation  = true;
        uploadModel.Sender         = file.Metadata.Sender;

        return(this.View("Index", uploadModel));
    }
Exemplo n.º 3
0
    public IActionResult Index()
    {
        UploadLinkModel model = UploadModelFactory.CreateLink();

        return(this.View(model));
    }
Exemplo n.º 4
0
    public IActionResult Index()
    {
        UploadModel uploadModel = UploadModelFactory.Create();

        return(this.View(uploadModel));
    }