mirror of
https://git.pleroma.social/sjw/pleroma.git
synced 2025-01-17 17:59:55 +01:00
Merge branch 'fix/s3/filenames-with-spaces' into 'develop'
Uploaders.S3: Replace unsafe characters in object key See merge request pleroma/pleroma!359
This commit is contained in:
commit
3de12c194f
@ -10,7 +10,7 @@ defmodule Pleroma.Uploaders.S3 do
|
|||||||
|
|
||||||
File.rm!(path)
|
File.rm!(path)
|
||||||
|
|
||||||
s3_name = "#{uuid}/#{name}"
|
s3_name = "#{uuid}/#{encode(name)}"
|
||||||
|
|
||||||
{:ok, _} =
|
{:ok, _} =
|
||||||
ExAws.S3.put_object(bucket, s3_name, file_data, [
|
ExAws.S3.put_object(bucket, s3_name, file_data, [
|
||||||
@ -21,4 +21,8 @@ defmodule Pleroma.Uploaders.S3 do
|
|||||||
|
|
||||||
{:ok, "#{public_endpoint}/#{bucket}/#{s3_name}"}
|
{:ok, "#{public_endpoint}/#{bucket}/#{s3_name}"}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp encode(name) do
|
||||||
|
String.replace(name, ~r/[^0-9a-zA-Z!.*'()_-]/, "-")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user