Exemple #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            var tempPath = Path.Combine(env.ContentRootPath, "temp");

            CreateDirectory(tempPath);

            app.UseTus(context => new DefaultTusConfiguration
            {
                //Local onde os arquivos temporários serão salvos
                Store = new TusDiskStore(tempPath),
                // URL onde os uploads devem ser realizados.
                UrlPath = "/upload",
                Events  = new Events
                {
                    //O que fazer quando o upload for finalizado
                    OnFileCompleteAsync = async ctx =>
                    {
                        var file = await((ITusReadableStore)ctx.Store).GetFileAsync(ctx.FileId, ctx.CancellationToken);
                        await ProcessFile.SaveFileAsync(file, env);
                    }
                }
            });

            app.UseStaticFiles();
        }