node-akamai-http-api
Akamai NetStorage HTTP API for Node.js (Unofficial).
- Official library might be found here
(though, the quality of this library is suspicious).
Installation
"dependencies": {
"akamai-http-api": "0.6.*" // see the "releases" section
}
npm update
Initialization
var akamai = ;akamai;
Notices
- You have to enable the netstorage HTTP API access using the control.akamai.com website
- Ensure there are no more than 15 operations/second on netstorage, otherwise you can expect netstorage to serve 500 errors.
- Double check the
host
value. In case of typo (fe:test.upload.akamai.com
), the client just sits there trying to open up a socket. Default timeout is20s
.
API
Advanced
upload
var fs = stream = fs;akamai;
download
var fs = stream = fs;akamai;
mtime
akamai;
Basic
du
akamai;
dir
akamaidir'/12345/MyFolder' {};
stat
akamai;
delete
akamai;
mkdir
akamai;
rmdir
akamai;
rename
akamai;
symlink
akamai;
Helpers
fileExists
akamai;
Exceptions
For the communication netstorage HTTP API uses HTTP codes.
Hence, a number of methods may trigger an exception. For example mkdir
in case the target already exists.
Or symlink
in case the target doesn't exist.
To handle these exceptions the err
object has an abnormal code
attribute.
akamai;
How to extend it?
var akamai = _ = myAkamai = Object; // custom headers for the upload functionmyAkamai { var options = request: method: 'put' headers: _ ; stream; return this;}; // quick-delete function (you should enable it first!)myAkamai { var options = request: method: 'put' headers: action: 'quick-delete' 'quick-delete': 'imreallyreallysure' ; this; return this;}; // exporting outsidemoduleexports = myAkamai;
Tests
Docker
# modify test/akamai.js#19-21 first [sudo] docker build -t node-akamai-http-api .[sudo] docker run -ti --rm node-akamai-http-api
NVM
export AKAMAI_KEY_NAME="key_name"export AKAMAI_KEY="key"export AKAMAI_HOST="domain.akamaihd.net"nvm install [6, 8, 10, 12, etc.]npm installnpm test