storage icon indicating copy to clipboard operation
storage copied to clipboard

How to write blob into a network disk?

Open arivera12 opened this issue 5 years ago • 18 comments

I need to store a blob on a network disk/shared computer folder that is on the network. How can I achieve this?

arivera12 avatar Jul 13 '19 18:07 arivera12

Have you tried using file provider?

aloneguid avatar Jul 17 '19 20:07 aloneguid

This is the provider I am using ATM StorageFactory.Blobs.DirectoryFiles. Did I am missing something?

arivera12 avatar Jul 19 '19 03:07 arivera12

Hm I never tried to be honest with file shares. If it doesn't work you can add one and raise a PR.

aloneguid avatar Jul 19 '19 09:07 aloneguid

So file shares via UNC path cannot be used with StorageFactory.Blobs.DirectoryFiles? :(

maQus123 avatar Aug 14 '19 07:08 maQus123

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.

aloneguid avatar Aug 14 '19 07:08 aloneguid

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.

arivera12 avatar Aug 15 '19 23:08 arivera12

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 avatar Aug 16 '19 13:08 maQus123

@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.

arivera12 avatar Aug 16 '19 17:08 arivera12

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.

arivera12 avatar Aug 16 '19 17:08 arivera12

@aloneguid Any news on this?

maQus123 avatar Sep 05 '19 11:09 maQus123

@maQus123 did you try the above solution I wrote here?

arivera12 avatar Sep 09 '19 01:09 arivera12

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.

Jo0 avatar Apr 27 '20 16:04 Jo0

Can you provide in a pull request with this? I would be great as an extension method/s.

arivera12 avatar Apr 27 '20 18:04 arivera12

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.

Jo0 avatar Apr 29 '20 02:04 Jo0

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.

Jo0 avatar Apr 08 '21 02:04 Jo0

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.

dsoronda avatar Apr 09 '21 19:04 dsoronda

Any progress on this? The challenge would be to have a cross platform solution which also can access Samba-shares on Linux...

stiansol avatar Aug 16 '22 09:08 stiansol

Don't think there's much interest in this, but you're welcome to raise a PR.

aloneguid avatar Aug 16 '22 10:08 aloneguid