Transfer
downloadBuffer GET
Download a file into memory.
const { buffer } = await ns.downloadBufferAsync("/123456/static/logo.png");
const bytes = Buffer.from(buffer as unknown as string, "binary");ns.downloadBuffer("/123456/static/logo.png", (err, res, body) => {
if (!err) fs.writeFileSync("logo.png", Buffer.from(body!.buffer as unknown as string, "binary"));
});npx akamai-netstorage cat static/app.jsSignatures
downloadBufferAsync(ns_path: string): Promise<DownloadBufferResponse>
downloadBuffer(ns_path: string, callback: (err: any, res?: http.IncomingMessage, body?: DownloadBufferResponse) => void): void
Parameters
| Name | Type | Description |
|---|---|---|
ns_path | string | NetStorage file path (not a directory). |
Returns
DownloadBufferResponse
{ buffer, message: "Download Done." }
On the wire
| HTTP method | GET |
| X-Akamai-ACS-Action | version=1&action=download |
| Signed with | X-Akamai-ACS-Auth-Data and X-Akamai-ACS-Auth-Sign (HMAC-SHA256) |
| CLI | akamai-netstorage cat static/app.js |
Build and sign this request in the playground →
Notes
bufferis typed asBufferbut, as in every 1.x release, holds the bytes as a binary (latin1) string. Convert it withBuffer.from(…, "binary").