Skip to content

Commit

Permalink
report the correct 'Location' value form multipart uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
tburghart committed Mar 16, 2016
1 parent 0770bd7 commit 153da50
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion riak_test/src/rtcs_dev.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%% -------------------------------------------------------------------
%%
%% Copyright (c) 2013 Basho Technologies, Inc.
%% Copyright (c) 2013-2016 Basho Technologies, Inc.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
Expand Down
7 changes: 3 additions & 4 deletions riak_test/tests/xml_response_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@

-include_lib("eunit/include/eunit.hrl").
-include_lib("xmerl/include/xmerl.hrl").

-include("deps/erlcloud/include/erlcloud_aws.hrl").
-include_lib("erlcloud/include/erlcloud_aws.hrl").

-define(test_bucket(Label), "test-bucket-" Label).
-define(test_key(Label), "test-key-" Label).
Expand All @@ -46,7 +45,7 @@ verify_multipart_upload_response() ->
rtcs:set_conf({cs, current, 1}, [{root_host, Host}]),
{AdminConfig, _} = rtcs:setup(1),
% erlcloud requires that 's3_host' matches our 'root_host'
% TODO: read this from the conf file
% TODO: rtcs:setup should read this from the conf file
Config = AdminConfig#aws_config{s3_host = Host},

lager:info("creating bucket ~p", [Bucket]),
Expand All @@ -68,7 +67,7 @@ perform_multipart_upload(Bucket, Key, NumParts, PartSize, Config) ->
lager:info("uploading parts of '~s/~s'", [Bucket, Key]),
EtagList = upload_and_assert_parts(
Bucket, Key, UploadId, NumParts, PartSize, Config),
lager:info("ETags of '~s/~s': ~p", [Bucket, Key, EtagList]),
% lager:info("ETags of '~s/~s': ~p", [Bucket, Key, EtagList]),

lager:info("completing upload of '~s/~s'", [Bucket, Key]),
complete_multipart_upload(Bucket, Key, UploadId, EtagList, Config).
Expand Down
9 changes: 7 additions & 2 deletions src/riak_cs_config.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%% ---------------------------------------------------------------------
%%
%% Copyright (c) 2007-2013 Basho Technologies, Inc. All Rights Reserved.
%% Copyright (c) 2007-2016 Basho Technologies, Inc. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
Expand Down Expand Up @@ -66,7 +66,8 @@
detailed_storage_calc/0,
quota_modules/0,
active_delete_threshold/0,
fast_user_get/0
fast_user_get/0,
root_host/0
]).

%% Timeouts hitting Riak
Expand Down Expand Up @@ -428,6 +429,10 @@ active_delete_threshold() ->
fast_user_get() ->
get_env(riak_cs, fast_user_get, false).

-spec root_host() -> string().
root_host() ->
get_env(riak_cs, cs_root_host, ?ROOT_HOST).

%% ===================================================================
%% ALL Timeouts hitting Riak
%% ===================================================================
Expand Down
9 changes: 6 additions & 3 deletions src/riak_cs_wm_object_upload_part.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%% ---------------------------------------------------------------------
%%
%% Copyright (c) 2007-2013 Basho Technologies, Inc. All Rights Reserved.
%% Copyright (c) 2007-2016 Basho Technologies, Inc. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
Expand Down Expand Up @@ -127,8 +127,7 @@ process_post(RD, Ctx=#context{local_context=LocalCtx, riak_client=RcPid}) ->
XmlDoc = {'CompleteMultipartUploadResult',
[{'xmlns', "http://s3.amazonaws.com/doc/2006-03-01/"}],
[
%% TODO: use cs_root from app.config
{'Location', [lists:append(["http://", binary_to_list(Bucket), ".s3.amazonaws.com/", Key])]},
{'Location', [response_location(Bucket, Key)]},
{'Bucket', [Bucket]},
{'Key', [Key]},
{'ETag', [ETag]}
Expand All @@ -144,6 +143,10 @@ process_post(RD, Ctx=#context{local_context=LocalCtx, riak_client=RcPid}) ->
end
end.

response_location(Bucket, Key) ->
lists:append(["http://",
binary:bin_to_list(Bucket), ".", riak_cs_config:root_host(), "/", Key]).

-spec valid_entity_length(#wm_reqdata{}, #context{}) -> {boolean(), #wm_reqdata{}, #context{}}.
valid_entity_length(RD, Ctx) ->
MaxLen = riak_cs_lfs_utils:max_content_len(),
Expand Down

5 comments on commit 153da50

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from kuenishi
at 153da50

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging basho/riak_cs/basho-trb-rcs-318 = 153da50 into borshop-integration-1302-basho-trb-rcs-318

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basho/riak_cs/basho-trb-rcs-318 = 153da50 merged ok, testing candidate = 7b6a19e

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding 2.1 to borshop-integration-1302-basho-trb-rcs-318 = 7b6a19e

Please sign in to comment.