mirror of
https://0xacab.org/sutty/sutty
synced 2025-01-19 11:23:40 +00:00
normalizar los nombres de archivo enviados por subida directa
This commit is contained in:
parent
455070f2ea
commit
30bc14d83e
1 changed files with 11 additions and 0 deletions
|
@ -11,6 +11,17 @@ module ActiveStorage
|
||||||
blob = ActiveStorage::Blob.create_before_direct_upload!(service_name: session[:service_name], **blob_args)
|
blob = ActiveStorage::Blob.create_before_direct_upload!(service_name: session[:service_name], **blob_args)
|
||||||
render json: direct_upload_json(blob)
|
render json: direct_upload_json(blob)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# Normalizar los caracteres unicode en los nombres de archivos
|
||||||
|
# para que puedan propagarse correctamente a través de todo el
|
||||||
|
# stack.
|
||||||
|
def blob_args
|
||||||
|
params.require(:blob).permit(:filename, :byte_size, :checksum, :content_type, metadata: {}).to_h.symbolize_keys.tap do |ba|
|
||||||
|
ba[:filename] = ba[:filename].unicode_normalize(:nfkc)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue