akamai / Netstoragekit Java
Licence: apache-2.0
Stars: ✭ 17
Programming Languages
java
68154 projects - #9 most used programming language
NetStorageKit (for Java)
This library assists in the interaction with Akamai's NetStorage CMS API. The following CMS API Specs are available:
Project organization
- /src - project sources
- /test - junit test cases
- /build - build and output libraries
- /doc - javadoc for class libraries
- /lib - 3rd party dependency libraries (Currenly only necessary for running unit tests)
- /example - an example app that utilizes the NetStorageKit
Install
- Compile the sources from
/src
intobuild/classes
. - An ant
build.xml
is also provided for ease of use. Common commands are:ant compile
,ant jar
andant test
- A maven
pom.xml
is also provided for ease of use. To install:mvn install
- Both IntelliJ and Eclipse project files are available
- the destination jar file is located in build/jar
Getting Started
- Create an instance of the
NetStorage
object by passing in the host, username and key - Issue a command to NetStorage by calling the appropriate method from the
NetStorage
object
For example, to delete a file:
import com.akamai.netstorage.NetStorage;
import com.akamai.netstorage.DefaultCredential;
DefaultCredential credential = new DefaultCredential("example.akamaihd.net","id of your upload account", "apiKey of upload account");
NetStorage ns = new NetStorage(credential);
ns.delete("/[CP Code]/example.zip");
Other methods return an InputStream
. For example, to retrieve a directory listing:
import com.akamai.netstorage.NetStorage;
import com.akamai.netstorage.DefaultCredential;
DefaultCredential credential = new DefaultCredential("example.akamaihd.net","id of your upload account", "apiKey of upload account");
NetStorage ns = new NetStorage(credential);
try (InputStream result = ns.dir("/[CP code]/1234")) {
// TODO: consume InputStream
}
Finally, when uploading a File
object can be sent or an open InputStream
wll be used
import com.akamai.netstorage.NetStorage;
import com.akamai.netstorage.DefaultCredential;
DefaultCredential credential = new DefaultCredential("example.akamaihd.net","id of your upload account", "apiKey of upload account");
NetStorage ns = new NetStorage(credential);
try (InputStream result = ns.upload("/[CP code]/1234/example.zip", new File("../workingdir/srcfile.zip"))) {
// TODO: consume InputStream
}
Sample application (CMS)
- A sample application has been created that can take command line parameters.
java -classpath build/classes CMS -a dir -u user1 -k 1234abcd example.akamaihd.net/1234
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].