You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I attempt to head one of these objects, it returns a 404 because the extra slash at the beginning of the object key is stripped off by normalize_path/1
defp normalize_path(url) do
url |> Map.update(:path, "", &String.replace(&1, ~r/\/{2,}$/, "/"))
end
This allows bucket listing (which needs the trailing / stripped) to continue to work and also allows objects with and without the prepended / on the key to be operated on.
Note
I'm near certain that I'm blind to a use case that requires stripping a number of slashes out of it, else this would have been a PR. Thought I'd kick off a dialog and see what shakes out.
Thanks for all the work you've done on ex_aws!
The text was updated successfully, but these errors were encountered:
MisterToolbox
changed the title
ExAws.Request.Url.normalize_path/1 breaks operations on S3 objects with multiple slashes in key name
ExAws.Request.Url.normalize_path/1 breaks operations on S3 objects with slashes at start of key name
Mar 23, 2018
The function that normalizes paths for AWS operations will cause operations on S3 objects with a
/
as their first character to fail.Environment
Current behavior
I've got a bucket that a third-party technology populated with objects whose keys begin with a
/
:(I've added two debug logs to the
normalize_path/1
function to see the URL before and after it transforms it)If I attempt to head one of these objects, it returns a 404 because the extra slash at the beginning of the object key is stripped off by
normalize_path/1
Workaround
Changing the
normalize_path/1
function defp to:This allows bucket listing (which needs the trailing
/
stripped) to continue to work and also allows objects with and without the prepended/
on the key to be operated on.Note
I'm near certain that I'm blind to a use case that requires stripping a number of slashes out of it, else this would have been a PR. Thought I'd kick off a dialog and see what shakes out.
Thanks for all the work you've done on ex_aws!
The text was updated successfully, but these errors were encountered: