WebDavServer
WebDavServer copied to clipboard
Read-Only FileSystem
Thanks for good product !
I am trying to make a read-only file system ,based on DotNetFileSystem but with a access list from database. this code works (the DNFS taking the list of files from SQL, and the files from the disk).
I tried to find the Options header list, on the source code, found all the HTTP Methods.
I am trying to remove the COPY, MOVE, etc, but could not remove them, as they scan for IHandler without the option to disable it .
For now I was found this (ugly) way, but Windows is trying to update the files or create files like desktop.ini, and similar.
public async Task<Stream> CreateAsync(CancellationToken cancellationToken) {
throw new ArgumentException("cant write");
}
I tried also to rewrite the AddWebDav function, but its a ugly workaround.
How to implement a ReadOnly attr, so the client will recognise the status and will not try to modify/lock the files ?
just to document a better ugly way:
services.Remove(services.Where(f => f.ServiceType == typeof(FubarDev.WebDavServer.Handlers.ICopyHandler)).First());
services.Remove(services.Where(f => f.ServiceType == typeof(FubarDev.WebDavServer.Handlers.IMoveHandler )).First());
services.Remove(services.Where(f => f.ServiceType == typeof(FubarDev.WebDavServer.Handlers.IDeleteHandler)).First());
services.Remove(services.Where(f => f.ServiceType == typeof(FubarDev.WebDavServer.Handlers.IPutHandler )).First());
Windows still show the option to create files, but it did not try to create desktop.ini and its friends.
I'm not sure if this is possible, because I couldn't find out whether MKCOL, etc.. are required for WebDAV 1 compliance.
MKCOL is writing on objects, I understand right ?
thanks for all
It's for creating a new collection (directory).
I thought a bit about your problem. I guess the following solution would be what you really need:
- Remove the
OptionsHandler(serviceIOptionsHandler) - Register your own service returning only the HTTP methods that you want to allow
The allowed HTTP methods are returned in the Allow header.
EDIT: This allows returning a different Allow HTTP header per location.
nice.
Thanks !
Is this issue going to be solved?
I think your solution is to add a read-only implementation of IOptionsHandler. Am I right?
I'm not familiar with this. Is WebDavOptionsResult that contains Allow header? If so, is it better to use an Attribute or a property to indicate whether a filesystem is readonly?
Besides, I saw WebDavDispatcherClass1 and think this is where HTTP Allow header is set, but it seems this class is not used at all, which makes me confused.