Upload filter: anonymize filename
It replaces the original filename with a randomly generated string.
This commit is contained in:
parent
ca24ad2a2b
commit
e9982c521b
2 changed files with 24 additions and 0 deletions
10
lib/pleroma/upload/filter/anonymize_filename.ex
Normal file
10
lib/pleroma/upload/filter/anonymize_filename.ex
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
defmodule Pleroma.Upload.Filter.AnonymizeFilename do
|
||||
@moduledoc "Replaces the original filename with a randomly generated string."
|
||||
@behaviour Pleroma.Upload.Filter
|
||||
|
||||
def filter(upload) do
|
||||
extension = List.last(String.split(upload.name, "."))
|
||||
string = Base.url_encode64(:crypto.strong_rand_bytes(10), padding: false)
|
||||
{:ok, %Pleroma.Upload{upload | name: string <> "." <> extension}}
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue