Skip to content

Instantly share code, notes, and snippets.

@mocchira
Created October 23, 2013 08:59
Show Gist options
  • Save mocchira/7115076 to your computer and use it in GitHub Desktop.
Save mocchira/7115076 to your computer and use it in GitHub Desktop.
calc AWS Auht header with leofs default user
-module(s3siggen).
-export([gen_sig/2]).
-include("leo_s3_auth.hrl").
-define(S3_ACC_KEY, "05236").
-define(S3_SEC_KEY, "802562235").
-define(S3_CONTENT_TYPE, "application/octet-stream").
%% ====================================================================
%% API
%% ====================================================================
gen_sig(HTTPMethod, Path) ->
[Bucket|_] = string:tokens(Path, "/"),
SignParams = #sign_params{http_verb = HTTPMethod,
content_md5 = [],
content_type = ?S3_CONTENT_TYPE,
date = [],
bucket = Bucket,
uri = Path,
query_str = [],
amz_headers = []
},
Sig = leo_s3_auth:get_signature(?S3_SEC_KEY, SignParams),
io_lib:format("AWS ~s:~s", [?S3_ACC_KEY, Sig]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment