• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

jie123108/lua-resty-s3: a aws s3 client for ngx_lua

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

jie123108/lua-resty-s3

开源软件地址(OpenSource Url):

https://github.com/jie123108/lua-resty-s3

开源编程语言(OpenSource Language):

Lua 78.9%

开源软件介绍(OpenSource Introduction):

Name

amazon s3 client for ngx_lua.

Implementation of the Amazon signature V4: http://docs.aws.amazon.com/zh_cn/AmazonS3/latest/API/sig-v4-authenticating-requests.html.

Usage

To load this library

you need to specify this library's path in ngx_lua's lua_package_path directive. For example:

http {
   lua_package_path '/path/to/lua-resty-s3/lib/?.lua;;';
}

you use require to load the library into a local Lua variable:

local awss3 = require("resty.s3")

Methods

-- require package
local awss3 = require "resty.s3"

-- init instance.
local s3 = awss3:new(AWSAccessKeyId, AWSSecretAccessKey, aws_bucket, {timeout=1000*10})

-- get a object. http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html
local ok, response = s3:get(key)

-- get a object. http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectHEAD.html
local ok, response = s3:head(key)

-- put a object. http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html
local ok, response = s3:put(key, value, headers)

-- delete a object. http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETE.html
local ok, response = s3:delete(key)

-- delete multi objects. http://docs.aws.amazon.com/AmazonS3/latest/API/multiobjectdeleteapi.html
local ok, response = s3:deletes(keys, quiet)

-- list files. http://docs.aws.amazon.com/AmazonS3/latest/API/v2-RESTBucketGET.html
local ok, files = s3:list(prefix, delimiter, page_size, marker)

-- copy files.  https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html
local ok, response = s3:copy(key, source, headers)

-- -- signature-v4. http://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html
local authorization, signature, extinfo = s3:authorization_v4(method, url, headers)

depends

test

install test dependencies

opm get jie123108/lua-resty-test

run the signature-v4-test-suite

cd path/to/lua-resty-s3
resty -I lib test/aws-sig-v4-test-suite.lua

Run the signature examples on the AWS website.

Signature Examples On AWS Website

resty -I lib test/test-s3-sign-examples.lua

Run s3 tests

Testing with Minio

Using docker to run minio:
    1. Startup minio container
docker run -d -it --name s3 -p 9000:9000 \
-e MINIO_ACCESS_KEY=THE_ACCESS_KEY_ID \
-e MINIO_SECRET_KEY=THE_SECRET_ACCESS_KEY \
minio/minio server /data/minio_data
    1. Access the minio console: http://127.0.0.1:9000/minio/
    • Access Key: THE_ACCESS_KEY_ID
    • Secret Key: THE_SECRET_ACCESS_KEY
    1. Add a storage bucket named `def' in the console
    • Once logged in, click the + button in the lower right corner and click the Create bucket in the pop-up menu.
Run Tests:
resty -I lib test/test-s3.lua

Testing with aws s3

S3_CONFIG="S3_ACCESS_ID:S3_ACCESS_SECERT_KEY:s3_bucket_name:s3_region" resty -I lib test/test-s3.lua

Licence

This module is licensed under the 2-clause BSD license.

Copyright (c) 2017, Xiaojie Liu [email protected]

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 AN Y 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 (INCLUD ING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap