diff --git a/Project.toml b/Project.toml index a6f1c183..99b17f4a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "AWSS3" uuid = "1c724243-ef5b-51ab-93f4-b0a88ac62a95" -version = "0.9.6" +version = "0.9.7" [deps] AWS = "fbe9abb3-538b-5e4e-ba9e-bc94f4f92ebc" diff --git a/src/AWSS3.jl b/src/AWSS3.jl index f1579090..c6129b2d 100644 --- a/src/AWSS3.jl +++ b/src/AWSS3.jl @@ -58,6 +58,13 @@ const SSDict = Dict{String,String} const AbstractS3Version = Union{AbstractString,Nothing} const AbstractS3PathConfig = Union{AbstractAWSConfig,Nothing} +# Utility function to workaround https://github.com/JuliaCloud/AWS.jl/issues/547 +function get_robust_case(x, key) + lkey = lowercase(key) + haskey(x, lkey) && return x[lkey] + return x[key] +end + __init__() = FilePathsBase.register(S3Path) # Declare new `parse` function to avoid type piracy @@ -837,7 +844,7 @@ function s3_upload_part( kwargs..., ) - return Dict(response.headers)["ETag"] + return get_robust_case(Dict(response.headers), "ETag") end function s3_complete_multipart_upload( diff --git a/src/s3path.jl b/src/s3path.jl index 54b53344..7ce5bb8b 100644 --- a/src/s3path.jl +++ b/src/s3path.jl @@ -358,9 +358,9 @@ function Base.stat(fp::S3Path) # Example: "Thu, 03 Jan 2019 21:09:17 GMT" last_modified = DateTime( - resp["Last-Modified"][1:(end - 4)], dateformat"e, d u Y H:M:S" + get_robust_case(resp, "Last-Modified")[1:(end - 4)], dateformat"e, d u Y H:M:S" ) - s = parse(Int, resp["Content-Length"]) + s = parse(Int, get_robust_case(resp, "Content-Length")) blocks = ceil(Int, s / 4096) end diff --git a/test/awss3.jl b/test/awss3.jl index a5c93b05..526a212a 100644 --- a/test/awss3.jl +++ b/test/awss3.jl @@ -3,6 +3,14 @@ function awss3_tests(config) "ocaws.jl.test." * lowercase(Dates.format(now(Dates.UTC), df)) end + @testset "Robust key selection" begin + lower_dict = Dict("foo-bar" => 1) + upper_dict = Dict("Foo-Bar" => 1) + @test AWSS3.get_robust_case(lower_dict, "Foo-Bar") == 1 + @test AWSS3.get_robust_case(upper_dict, "Foo-Bar") == 1 + @test_throws KeyError("Foo-Bar") AWSS3.get_robust_case(Dict(), "Foo-Bar") + end + @testset "Create Bucket" begin s3_create_bucket(config, bucket_name) @test bucket_name in s3_list_buckets(config)