lib/omnibus/s3_helpers.rb in omnibus-6.0.1 vs lib/omnibus/s3_helpers.rb in omnibus-6.0.24
- old
+ new
@@ -12,11 +12,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require "aws-sdk"
+require "aws-sdk-s3"
require "aws-sdk-core/credentials"
require "aws-sdk-core/shared_credentials"
require "base64"
module Omnibus
@@ -66,11 +66,11 @@
#
# @return [Hash]
#
def resource_params
params = {
- use_accelerate_endpoint: s3_configuration[:use_accelerate_endpoint],
+ use_accelerate_endpoint: s3_configuration[:use_accelerate_endpoint],
force_path_style: s3_configuration[:force_path_style],
}
if s3_configuration[:use_accelerate_endpoint]
params[:endpoint] = "https://s3-accelerate.amazonaws.com"
@@ -91,10 +91,13 @@
def get_credentials
if s3_configuration[:profile]
Aws::SharedCredentials.new(profile_name: s3_configuration[:profile])
elsif s3_configuration[:access_key_id] && s3_configuration[:secret_access_key]
Aws::Credentials.new(s3_configuration[:access_key_id], s3_configuration[:secret_access_key])
+ else
+ # No credentials specified, only public data will be retrievable
+ Aws::Credentials.new(nil, nil)
end
end
#
# The bucket where the objects live.
@@ -124,19 +127,18 @@
# @param [String] key
# @param [File, String] content
# @param [String] content_md5
# @param [String] acl
#
- # @return [true]
+ # @return [Aws::S3::Object]
#
def store_object(key, content, content_md5, acl)
bucket.put_object({
key: key,
body: content,
content_md5: to_base64_digest(content_md5),
acl: acl,
})
- true
end
#
# Convert a hex digest into a base64 hex digest
#