PHPackages                             saguajardo/netstorage - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. saguajardo/netstorage

ActiveLibrary[File &amp; Storage](/categories/file-storage)

saguajardo/netstorage
=====================

Akamai Netstorage Library

0444PHP

Since Aug 8Pushed 3y ago1 watchersCompare

[ Source](https://github.com/saguajardo/netstorage)[ Packagist](https://packagist.org/packages/saguajardo/netstorage)[ RSS](/packages/saguajardo-netstorage/feed)WikiDiscussions main Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Netstorage API library package for Akamai
-----------------------------------------

[](#netstorage-api-library-package-for-akamai)

This package follows [facade design pattern](https://en.wikipedia.org/wiki/Facade_pattern) (Click on the link to read more on this).

### Features:

[](#features)

1. Upload a file to Akamai Netstorage
2. List the files and directories of a given directory
3. Download a file
4. Delete a file
5. Rename a file
6. Remove a directory (Directory must be empty to remove)
7. Create a new directory
8. Generate Video Auth token for playback

### Sample `.env.akamai`

[](#sample-envakamai)

```
AKAMAI_HOST="Your Netstorage Host"
AKAMAI_KEY="Your Netstorage Key"
AKAMAI_KEYNAME="Your Netstorage Key Name"
AKAMAI_VIDEO_TOKEN="Your Video Token"

```

### Explanation:

[](#explanation)

This package has three facade classes

#### 1) Akamai\\Facades\\Config

[](#1-akamaifacadesconfig)

##### Introduction:

[](#introduction)

`Config` facade is used to load/set the credentials which are used for API requests

##### Methods:

[](#methods)

###### 1) Config::loadFromENV($path, $name);

[](#1-configloadfromenvpath-name)

This method is used to load the credentials from an `env` file. This method will try to load all four env variables which are mentioned in the sample `.env.akamai` file.

```
/*
    @param: $path - Path of the env file. Default is current working directory.
    @param: $name - Name of the env file to load. Default is `.env.akamai`.
    @return: Array - Loaded configuration.
    @throws: Akamai\Exceptions\DotEnvException.
*/

```

###### 2) Config::setAkamaiConfig($config)

[](#2-configsetakamaiconfigconfig)

This method is to set the credentials in runtime. Will be usefull when the credentials are stored in database or any other mode of storage.

```
/*
    @param: $config - Configuration to be updated.
    @return: Array - Loaded configuration.
    @throws: Akamai\Exceptions\InvalidDataTypeFoundException;
*/

```

###### 3) Config::getAkamaiConfig()

[](#3-configgetakamaiconfig)

This method is to get the credentials in runtime.

```
/*
    @return: Array - Loaded configuration.
*/

```

#### 2) Akamai\\Facades\\Akamai

[](#2-akamaifacadesakamai)

##### Introduction:

[](#introduction-1)

`Akamai` facade is used to do the basic operations like upload, download etc. All API operations return responses as an array with fields for "data" and "code".

```
/*
    [
        "data" => API response (simple string or xml string),
        "code" => API response status code
    ]
*/

```

For a list of all possible status codes, see [https://control.akamai.com/dl/customers/NS/NS\_http\_api\_FS.pdf](https://control.akamai.com/dl/customers/NS/NS_http_api_FS.pdf)

##### Methods:

[](#methods-1)

###### 1) Akamai::upload($akamai\_path, $file\_path);

[](#1-akamaiuploadakamai_path-file_path)

This method is used to upload a file to Akamai.

```
/*
    @param: $akamai_path - File location with file name and extension to which the file should be uploaded. ex: /cpcode/folder/path/file.mp4
    @param: $file_path - Path to the file to be written.
    @return: Array - ["data" => API response, "code" => API response status code]
*/

```

###### 2) Akamai::dir($akamai\_path);

[](#2-akamaidirakamai_path)

This method is used to list the files in a particular directory.

```
/*
    @param: $akamai_path - Directory path to be listed. ex: /cpcode/folder/path
    @return: Array - ["data" => API response, "code" => API response status code]
*/

```

###### 3) Akamai::download($akamai\_path);

[](#3-akamaidownloadakamai_path)

This method is to download a file

```
/*
    @param: $akamai_path - File location with file name and extension. ex: /cpcode/folder/path/file.mp4
    @return: Array - ["data" => API response (contents of file on success), "code" => API response status code]
*/

```

###### 4) Akamai::delete($akamai\_path);

[](#4-akamaideleteakamai_path)

This method is to delete a file

```
/*
    @param: $akamai_path - File location with file name and extension. ex: /cpcode/folder/path/file.mp4
    @return: Array - ["data" => API response, "code" => API response status code]
*/

```

###### 5) Akamai::rename($old\_akamai\_path, $new\_akamai\_path);

[](#5-akamairenameold_akamai_path-new_akamai_path)

This method is to rename a file

```
/*
    @param: $old_akamai_path - Existing file location with file name and extension. ex: /cpcode/folder/path/file.mp4
    @param: $new_akamai_path - Desired file location with file name and extension. ex: /cpcode/new_folder/new_path/new_file.mp4
    @return: Array - ["data" => API response, "code" => API response status code]
*/

```

###### 6) Akamai::rmdir($akamai\_path);

[](#6-akamairmdirakamai_path)

This method is to delete a directory. \[CAUTION: Directory has to be empty. (ie, list and delete all files individually before performing this API call)\].

```
/*
    @param: $akamai_path - Directory path to be deleted. ex: /cpcode/folder/path
    @return: Array - ["data" => API response, "code" => API response status code]
*/

```

###### 7) Akamai::mkdir($akamai\_path);

[](#7-akamaimkdirakamai_path)

This method is to create a directory.

```
/*
    @param: $akamai_path - Directory path to be added. ex: /cpcode/folder/path
    @return: Array - ["data" => API response, "code" => API response status code]
*/

```

###### 8) Akamai::generateToken($duration, $type);

[](#8-akamaigeneratetokenduration-type)

\[DEPRECATED\] Please use Token facade to generate video tokens

This method is to generate video authentication token.

```
/*
    @param: $duration - Time to live (ttl) of that token. (In seconds)
    @param: $type - It should be `hdnts` or `hdnea`.
    @return: String - Final token which has to be appended with the m3u8 request.
*/

```

#### 3) Akamai\\Facades\\Token

[](#3-akamaifacadestoken)

##### Introduction:

[](#introduction-2)

`Token` facade is used to generate video auth tokens.

##### Methods:

[](#methods-2)

###### 1) Token::generateVideoToken($duration, $type);

[](#1-tokengeneratevideotokenduration-type)

This method is to generate video authentication token.

```
/*
    @param: $duration - Time to live (ttl) of that token. (In seconds)
    @param: $type - It should be `hdnts` or `hdnea`.
    @return: String - Final token which has to be appended with the m3u8 request.
*/

```

---

### Usage sample

[](#usage-sample)

```
 200
     *           ]
     */
    $dirResponse = Akamai::dir('/cpcode/directory/to/list');

    /** @var array */
    $uploadResponse = Akamai::upload('/cpcode/path/to/file/testing.mp4', './testing.mp4');
    /** @var string */
    $uploadResponseData = $uploadResponse["data"];
    /** @var int */
    $uploadResponseCode = $uploadResponse["code"];

    /** @var array */
    $downloadResponse = Akamai::download('/cpcode/path/to/file/testing.mp4');
    if ($downloadReponse["code"] === 200) {
        file_put_contents('./testing.mp4', $downloadResponse["data"]);
    } else {
        // perform some error handling based on status code
    }

    /** @var array - ['data' => "could be simple string or xml string",'code' => 200] */
    $renameResponse = Akamai::rename('/cpcode/path/to/file/testing.mp4', '/cpcode/new_path/to/file/new_testing.mp4');

    /** @var array - ['data' => "could be simple string or xml string",'code' => 200] */
    $deleteResponse = Akamai::delete('/cpcode/newpath/to/file/new_testing.mp4');

    /** @var array - ['data' => "could be simple string or xml string",'code' => 200] */
    $mkdirResponse = Akamai::mkdir('/cpcode/new_dir');

    /** @var array - ['data' => "could be simple string or xml string",'code' => 200] */
    $rmdirResponse = Akamai::rmdir('/cpcode/new_dir');

    $token = Token::generateVideoToken(100, "hdnts");
    var_dump($token);
    /**
     * hdnts=st=1470130755~exp=1470130855~acl=*~hmac=99665898830y435t37487889hl672055956t9p7455e14g765c056i413u433125;
     */

} catch (Exception $e) {
    echo $e->getMessage();
}
```

\###Change Log:

\####v3.1.0 Thanks to [Julian Griggs](https://github.com/JulianGriggs)

1. New mkdir and rename functions

\####v3.0.0 Thanks to [Julian Griggs](https://github.com/JulianGriggs)

1. Standardization of API
2. Refactor
3. Document update
4. Removed unwanted test

\####v2.0.1 Thanks to [Julian Griggs](https://github.com/JulianGriggs)

1. Added missing return statement for `delete` method.

\####v2.0.0

1. New `Token` facade
2. Code refactor
3. Bug fixes
4. Deprecated `Akamai::generateToken($duration, $type)`

\####v1.1.1

1. Issue fix
2. Document update

\####v1.1.0

1. Added video token api for generating tokens for video based on duration.

\####v1.0.3

1. Code optimization

\####v1.0.2

1. Issue fixes

\####v1.0.1

1. Issue fixes

\####v1.0.0

1. Initial version with support for upload, list directory, download, remove directory and delete

#### NOTE: This package is based on [Akamai plugin by Raben](https://github.com/raben/Akamai/). So credits goes to him. I have adapt to PHP version used in my project.

[](#note-this-package-is-based-on-akamai-plugin-by-raben-so-credits-goes-to-him-i-have-adapt-to-php-version-used-in-my-project)

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6fec1338a63d5ac6465b349438c9cd83b1894493ec441f7f50550415e0d84b69?d=identicon)[sguajardo](/maintainers/sguajardo)

---

Top Contributors

[![saguajardo](https://avatars.githubusercontent.com/u/18266295?v=4)](https://github.com/saguajardo "saguajardo (1 commits)")

### Embed Badge

![Health badge](/badges/saguajardo-netstorage/health.svg)

```
[![Health](https://phpackages.com/badges/saguajardo-netstorage/health.svg)](https://phpackages.com/packages/saguajardo-netstorage)
```

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M125](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
