Giter VIP home page Giter VIP logo

netstoragekit-java's Introduction

NetStorageKit (for Java)

Important

Akamai does not maintain or regulate this package. While it can be incorporated to assist you in API use, Akamai Technical Support will not offer assistance and Akamai cannot be held liable if issues arise from its use.

Overview

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 into build/classes.
  • An ant build.xml is also provided for ease of use. Common commands are: ant compile, ant jar and ant 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.