feat(s3): make acl optional
This commit is contained in:
parent
a99eb082d1
commit
e22c1c01ec
|
@ -199,10 +199,12 @@ format(#{aws_config := AwsConfig} = Client) ->
|
||||||
%% Internal functions
|
%% Internal functions
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
upload_options(Config) ->
|
upload_options(#{acl := Acl}) when Acl =/= undefined ->
|
||||||
[
|
[
|
||||||
{acl, maps:get(acl, Config)}
|
{acl, Acl}
|
||||||
].
|
];
|
||||||
|
upload_options(#{}) ->
|
||||||
|
[].
|
||||||
|
|
||||||
headers(#{headers := Headers}) ->
|
headers(#{headers := Headers}) ->
|
||||||
headers_user_to_erlcloud_request(Headers);
|
headers_user_to_erlcloud_request(Headers);
|
||||||
|
|
|
@ -198,7 +198,7 @@ client_config(ProfileConfig, PoolName) ->
|
||||||
port => maps:get(port, ProfileConfig),
|
port => maps:get(port, ProfileConfig),
|
||||||
url_expire_time => maps:get(url_expire_time, ProfileConfig),
|
url_expire_time => maps:get(url_expire_time, ProfileConfig),
|
||||||
headers => maps:get(headers, HTTPOpts, #{}),
|
headers => maps:get(headers, HTTPOpts, #{}),
|
||||||
acl => maps:get(acl, ProfileConfig),
|
acl => maps:get(acl, ProfileConfig, undefined),
|
||||||
bucket => maps:get(bucket, ProfileConfig),
|
bucket => maps:get(bucket, ProfileConfig),
|
||||||
access_key_id => maps:get(access_key_id, ProfileConfig, undefined),
|
access_key_id => maps:get(access_key_id, ProfileConfig, undefined),
|
||||||
secret_access_key => maps:get(secret_access_key, ProfileConfig, undefined),
|
secret_access_key => maps:get(secret_access_key, ProfileConfig, undefined),
|
||||||
|
|
|
@ -105,7 +105,7 @@ fields(s3) ->
|
||||||
#{
|
#{
|
||||||
default => private,
|
default => private,
|
||||||
desc => ?DESC("acl"),
|
desc => ?DESC("acl"),
|
||||||
required => true
|
required => false
|
||||||
}
|
}
|
||||||
)},
|
)},
|
||||||
{transport_options,
|
{transport_options,
|
||||||
|
|
|
@ -60,7 +60,8 @@ init_per_testcase(_TestCase, Config0) ->
|
||||||
ok = erlcloud_s3:create_bucket(Bucket, TestAwsConfig),
|
ok = erlcloud_s3:create_bucket(Bucket, TestAwsConfig),
|
||||||
Config1 = [
|
Config1 = [
|
||||||
{key, emqx_s3_test_helpers:unique_key()},
|
{key, emqx_s3_test_helpers:unique_key()},
|
||||||
{bucket, Bucket}
|
{bucket, Bucket},
|
||||||
|
{aws_config, TestAwsConfig}
|
||||||
| Config0
|
| Config0
|
||||||
],
|
],
|
||||||
{ok, PoolName} = emqx_s3_profile_conf:start_http_pool(?PROFILE_ID, profile_config(Config1)),
|
{ok, PoolName} = emqx_s3_profile_conf:start_http_pool(?PROFILE_ID, profile_config(Config1)),
|
||||||
|
@ -131,6 +132,16 @@ t_url(Config) ->
|
||||||
httpc:request(Url)
|
httpc:request(Url)
|
||||||
).
|
).
|
||||||
|
|
||||||
|
t_no_acl(Config) ->
|
||||||
|
Key = ?config(key, Config),
|
||||||
|
|
||||||
|
ClientConfig = emqx_s3_profile_conf:client_config(
|
||||||
|
profile_config(Config), ?config(ehttpc_pool_name, Config)
|
||||||
|
),
|
||||||
|
Client = emqx_s3_client:create(maps:without([acl], ClientConfig)),
|
||||||
|
|
||||||
|
ok = emqx_s3_client:put_object(Client, Key, <<"data">>).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Helpers
|
%% Helpers
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue