|
| 1 | +# NetStorageKit (for .NET/c#) |
| 2 | + |
| 3 | +This library assists in the interaction with Akamai's NetStorage CMS API. |
| 4 | + |
| 5 | +## Project organization |
| 6 | +* /NetStorage - core NetStorage project |
| 7 | +* /NetStorageTest - MSTest unit tests |
| 8 | +* /NetStorageExample - example CMS.exe implementation |
| 9 | +* /NetStorageAPI.sln - root VisualStudio solution |
| 10 | + |
| 11 | +## Install |
| 12 | +* Open the NetStorageAPI.sln in Visual Studio; Rebuild All |
| 13 | +* OR ```MSBuild.exe NetStorageAPI.sln /t:rebuild``` |
| 14 | +* Copy the Akamai.Netstorage.dll to your application or solution. (/NetStorage/obj/Debug/Akamai.Netstorage.dll or /NetStorage/obj/Release/Akamai.Netstorage.dll) |
| 15 | + |
| 16 | +## Getting Started |
| 17 | +* Create an instance of the `NetStorage` object by passing in the host, username and key |
| 18 | +* Issue a command to NetStorage by calling the appropriate method from the `NetStorage` object |
| 19 | + |
| 20 | +For example, to delete a file: |
| 21 | +```using Akamai.NetStorage; |
| 22 | +
|
| 23 | +NetStorage ns = new NetStorage("example.akamaihd.net", "user1", "1234abcd"); |
| 24 | +ns.Delete("/1234/example.zip"); |
| 25 | +``` |
| 26 | + |
| 27 | +Other methods return a `Stream`. For example, to retrieve a directory listing: |
| 28 | + |
| 29 | +```using Akamai.NetStorage; |
| 30 | +NetStorage ns = new NetStorage("example.akamaihd.net", "user1", "1234abcd"); |
| 31 | +
|
| 32 | +try (Stream result = ns.Dir("/1234")) { |
| 33 | + // TODO: consume Stream |
| 34 | +} |
| 35 | +``` |
| 36 | + |
| 37 | +Finally, when uploading a `FileInfo` object can be sent or an open `InputStream` wll be used |
| 38 | +```using Akamai.NetStorage; |
| 39 | +
|
| 40 | +NetStorage ns = new NetStorage("example.akamaihd.net", "user1", "1234abcd"); |
| 41 | +try (bool success = ns.Upload("/1234/example.zip", new FileInfo("../workingdir/srcfile.zip"))) { |
| 42 | + // TODO: log support |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | + |
| 47 | +## Sample application (CMS) |
| 48 | +* A sample application has been created that can take command line parameters. |
| 49 | + |
| 50 | +```CMS.exe -a dir -u user1 -k 1234abcd example.akamaihd.net/1234 |
| 51 | +``` |
| 52 | + |
0 commit comments