Flyers
Hi,
I’m trying to unzip an uploaded file and store the compressed files to my database. I’ve a working process but I’ve just discovered that files with non ascii chars in names are stored weirdly in my postgres database.
How I unzip and save file is :
with {:ok, handle} <- :zip.zip_open(path, [{:cwd, path_name}]),
{:ok, file_names} = :zip.zip_get(handle) do
try do
filter_hidden_files(file_names)
|> to_plug_upload()
|> to_multi(user, kind, Multi.new())
|> Repo.transaction()
after
:zip.zip_close(handle)
end
end
defp filter_hidden_files(_, files \\ [])
defp filter_hidden_files([], files) do
files
end
defp filter_hidden_files([file | tail], files) do
filename = Path.basename(file)
case String.first(filename) === "." do
true -> filter_hidden_files(tail, files)
false -> filter_hidden_files(tail, files ++ [file])
end
end
defp to_plug_upload(_, uploads \\ [])
defp to_plug_upload([], uploads) do
uploads
end
defp to_plug_upload([file | tail], uploads) do
upload = %Plug.Upload{
content_type: MIME.from_path(file),
filename: Path.basename(file),
path: to_string(file)
}
to_plug_upload(tail, uploads ++ [upload])
end
defp to_multi([], %User{}, _kind, multi) do
multi
end
defp to_multi(
[file | tail],
%User{entity_name: entity_name} = user,
kind,
multi
) do
attrs = %{
brand: entity_name,
name: file,
kind: kind,
file_hash: file_hash(file),
file_name: file.filename
}
m =
%Media{}
|> Media.changeset(attrs)
to_multi(tail, user, kind, multi |> Multi.insert(file.filename, m))
end
When I try to upload and save a file called 2809575_xxléàî.jpg I get the following saved in database 2809575_xxleÌaÌiÌ.jpg?63728256310
I think there is an encoding problem when reading files using erlang :zip module.
Thanks.
Trending in Questions
One of my LiveView view’s has a very heavy javascript dependency so I want to avoid loading it for every page on the site, while still us...
New
Hi all!
I know that quite a few people use Phoenix LiveView but it is hard to get a more up-to-date list of folks/companies using it. I ...
New
Hello everyone!
I am new to coding with Elixir/Erlang. And i am looking for some utilities for fuzzing testing like AFL++.
Does anyone ...
New
I’m very new to Elixir, so sorry if this is a silly question:
I am wondering what happens to the mailbox of a process when the machine i...
New
I load tested a plain Phoenix chat app backed by Postgres with 100 million messages in it, everything on default settings, to see what br...
New
Background
When trying to execute mix release on a Windows 11 machine for a Phoenix project I get the following error:
* assembling mark...
New
I don’t suppose you can lazy load a library depending on runtime data? For example if it’s a certain user they can lazy load ‘library A’ ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hi everyone :waving_hand:
I’ve been working on PhiaUI, an open-source UI component library for Phoenix LiveView, and I wanted to share i...
New
On November 23, 2026, an unauthorized third party exploited a vulnerability in hex.pm (CVE-2026-129514, CVSS 10.0) that let them run comm...
New
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #code-sync
- #exunit
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #ai
- #authentication
- #elixirconf-us
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-eu
- #distillery
- #security
- #processes
- #api
- #forms
- #hex










Showing Posts 1 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
NobbZ
As far as I know, ZIP does not enforce any encoding of filenames, it is just saved as it comes from the operating system as raw bytes.
So how well non-asciis get carried over depends on where you zip and where you unzip, but as one does not use non-ascii in filenames, this in not a problem at all
If you know the encoding used by the “zipper”, then you should be able to use iconv like tools to transfer in any encoding you like.
Also remember, that you get double trouble if the encoding in the database differs from the encoding of data you write to it.