JuliaCloud / AWS.jl

Julia interface to AWS
MIT License
160 stars 62 forks source link

SignatureDoesNotMatch calling S3.delete_objects #675

Open maleadt opened 5 months ago

maleadt commented 5 months ago

Looking at https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html#API_DeleteObjects_RequestSyntax, this API needs to be invoked with a Delete>NxObject>Key hierarchy, which AWS.jl already provides the toplevel Delete entry: https://github.com/JuliaCloud/AWS.jl/blob/5ebf8caa636dc8f2d051aea70a69adc7d146cad4/src/services/s3.jl#L1570

Hence I figured I should call the functionality in here as such, passing a vector of dictionaries:

function s3_delete(aws::AbstractAWSConfig, bucket, paths::Vector; kwargs...)
    delete = []
    for path in paths
        push!(delete, Dict("Object" => Dict("Key" => path)))
    end

    return parse(S3.delete_objects(bucket, delete; aws_config=aws, kwargs...))
end

That however throws a signature error:

ERROR: AWS.AWSExceptions.AWSException: SignatureDoesNotMatch -- The request signature we calculated does not match the signature you provided. Check your key and signing method.

The delete object I pass is as follows:

1-element Vector{Any}:
 Dict("Object" => Dict("Key" => "nanosoldier/Convex1d.1.6.0-DEV-1f9e8bdbcf.log"))

Calling S3.delete_object with this key works fine.