storage
storage copied to clipboard
How to write blob into a network disk?
I need to store a blob on a network disk/shared computer folder that is on the network. How can I achieve this?
Have you tried using file provider?
This is the provider I am using ATM StorageFactory.Blobs.DirectoryFiles. Did I am missing something?
Hm I never tried to be honest with file shares. If it doesn't work you can add one and raise a PR.
So file shares via UNC path cannot be used with StorageFactory.Blobs.DirectoryFiles? :(
No I guess it's not, however it's easy to add, UNC support is part of .NET runtime. If there are any takes please do it, otherwise I'll implement it.
I would like to do this implementation but right now have too much workload. I don't need these feature for now but it would be a nice to have already cause there are some cases where customers host their own documents in another server rather were the web server resides. So basically we would need to access a network disc/shared computer to drop the files.
I need it now but unfortunetly also no time :( @aloneguid If you wouldn't mind implementing it I would be more than happy :) Without having a deeper look into it, but isn't UNC windows proprietary? Does that run on dotnet core?
@maQus123 I have done this in the past here is a sample code on how it should work.
NetworkCredential testCreds = new NetworkCredential("user", "password");
CredentialCache testCache = new CredentialCache();
testCache.Add(new Uri("\\\\192.168.5.5"), "Basic", testCreds);
File.Create("\\\\192.168.5.5\\testfolder\\test.txt");
UNC is windows proprietary but there are cross platform ports of UNC, for example for linux there is SAMBA combined with a tool called cifs-tool. Take a look of this link.
Looking around @aloneguid implementation it should not take too much longer to implement it. I think he just need to overload StorageFactory.Blobs.DirectoryFiles with credential cache.
@aloneguid Any news on this?
@maQus123 did you try the above solution I wrote here?
I can extend DiskDirectoryBlobStorage
or create a new IBlobStorage
for Network Shares.
I have a library right now that wraps SMB share access with System.IO.Abstractions
So it's essentially the same System.IO
calls, but you'll just need to provide credentials. Shouldn't be too much work and it kind of lends itself to how you have things setup.
Can you provide in a pull request with this? I would be great as an extension method/s.
It'll be a bit. I need to sort out some things I discovered in the library. Once that's all squared away I'll get a PR here for supporting network shares.
It's been awhile. Been caught up in work and life. Want to apologize to everyone who has been waiting for my PR. Not sure when I'll get around to it, but it's something that I eventually want to contribute to this project.
testCache.Add(new Uri("\\\\192.168.5.5"), "Basic", testCreds); File.Create("\\\\192.168.5.5\\testfolder\\test.txt");
Why not use @ for string ?
File.Create(@"\\192.168.5.5\testfolder\test.txt");
Compiling result is same but it's way more human readable.
Any progress on this? The challenge would be to have a cross platform solution which also can access Samba-shares on Linux...
Don't think there's much interest in this, but you're welcome to raise a PR.