Skip to content

rainingmaster/NetStorageKit-Lua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Name

NetStorageKit-Lua

Table of Contents

Description

NetStorageKit-Lua is Akamai Netstorage (File/Object Store) API for Lua(Openresty). And this module is ported from netstoragekit-golang. Before using this module, lua-resty-http and lua-resty-hmac should be installed.

Synopsis

List the environment variable name in nginx.conf file via the env directive for accessing in lua.

Add configs in main block

    env NS_KEY;
    env NS_HOST;
    env NS_KEYNAME;

Add configs in http block

    lua_package_path "/path/to/NetStorageKit-Lua/lib/?.lua;;";

    server {
        location /test {
            content_by_lua_block {
                local netstorage = require("resty.netstorage")

                -- Get parameters from os evironment, you can change to your own private value.
                local ns, err = netstorage:new({
                    key = os.getenv("NS_KEY"),
                    key_name = os.getenv("NS_KEYNAME"),
                    host = os.getenv("NS_HOST"),
                    ssl = true,
                })
                if not ns then
                    ngx.log(ngx.ERR, "init failed: ", err)
                    return ngx.exit(500)
                end

                local _, err, code = ns:upload("/10000/new_file", "hello netstorage here!")
                if err or code ~= 200 then
                    ngx.log(ngx.ERR, "upload failed: ", err, ", code: ", code)
                    return ngx.exit(500)
                end

                ngx.print("success")
                ns:set_keepalive()
            }
        }
    }

Back to TOC

Modules

Back to TOC

resty.netstorage

Back to TOC

Methods

Back to TOC

new

Back to TOC

dir

Back to TOC

du

Back to TOC

stat

Back to TOC

mkdir

Back to TOC

rmdir

Back to TOC

mtime

Back to TOC

delete

Back to TOC

quick_delete

Back to TOC

rename

Back to TOC

symlink

Back to TOC

download

Back to TOC

upload

Back to TOC

delete

Back to TOC

set_keepalive

Back to TOC

Installation

export LUA_LIB_DIR=/path/to/lualib && make install

Back to TOC

TODO

Back to TOC

Copyright and License

This module is licensed under the BSD license.

Copyright (C) 2018-2018, by rainingmaster.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Back to TOC

See Also

Back to TOC

About

Netstorage API for Lua(base on Openresty)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published