Commit 3de12c19 authored by kaniini's avatar kaniini
Browse files

Merge branch 'fix/s3/filenames-with-spaces' into 'develop'

Uploaders.S3: Replace unsafe characters in object key

See merge request !359
parents 72520550 f77ec967
Pipeline #3848 passed with stages
in 6 minutes and 17 seconds
......@@ -10,7 +10,7 @@ def put_file(name, uuid, path, content_type, _should_dedupe) do
File.rm!(path)
s3_name = "#{uuid}/#{name}"
s3_name = "#{uuid}/#{encode(name)}"
{:ok, _} =
ExAws.S3.put_object(bucket, s3_name, file_data, [
......@@ -21,4 +21,8 @@ def put_file(name, uuid, path, content_type, _should_dedupe) do
{:ok, "#{public_endpoint}/#{bucket}/#{s3_name}"}
end
defp encode(name) do
String.replace(name, ~r/[^0-9a-zA-Z!.*'()_-]/, "-")
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment