[Fixes] File sharing

This commit is contained in:
2017-04-11 01:19:35 +02:00
parent f0246d5ad1
commit a520cb00a0

View File

@ -29,13 +29,16 @@ namespace Yavsc
FileProvider = new PhysicalFileProvider(UserFilesDirName), FileProvider = new PhysicalFileProvider(UserFilesDirName),
RequestPath = new PathString(Constants.UserFilesPath), RequestPath = new PathString(Constants.UserFilesPath),
EnableDirectoryBrowsing = env.IsDevelopment() EnableDirectoryBrowsing = env.IsDevelopment()
}; };
UserFilesOptions.EnableDefaultFiles=true;
UserFilesOptions.StaticFileOptions.ServeUnknownFileTypes=true;
UserFilesOptions.StaticFileOptions.OnPrepareResponse += async context => UserFilesOptions.StaticFileOptions.OnPrepareResponse += async context =>
{ {
var uname = context.Context.User.GetUserName(); var uname = context.Context.User.GetUserName();
var path = context.Context.Request.Path; var path = context.Context.Request.Path;
var result = await authorizationService.AuthorizeAsync(context.Context.User, new ViewFileContext var result = await authorizationService.AuthorizeAsync(context.Context.User, new ViewFileContext
{ UserName = uname, File = context.File, Path = path } , new ViewRequirement()); { UserName = uname, File = context.File, Path = path } , new ViewRequirement());
}; };
var avatarsDirInfo = new DirectoryInfo(Startup.SiteSetup.UserFiles.Avatars); var avatarsDirInfo = new DirectoryInfo(Startup.SiteSetup.UserFiles.Avatars);