Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid Unicode Upload from Liveview Upload? #2

Closed
rhh4x0r opened this issue Oct 20, 2024 · 5 comments · Fixed by supabase-community/supabase-ex#53 or #3
Closed

Invalid Unicode Upload from Liveview Upload? #2

rhh4x0r opened this issue Oct 20, 2024 · 5 comments · Fixed by supabase-community/supabase-ex#53 or #3

Comments

@rhh4x0r
Copy link

rhh4x0r commented Oct 20, 2024

I'm attempting to upload a file to supabase with this but I'm getting :invalid_unicode during streaming errors. I've tried with different mp3 files, and still :invalid_unicode.

Here's what the path of an object looks like ""/tmp/plug-1729-wEti/live_view_upload-1729464552-93643243762403-4" -- if I add .mp3 ofter that it won't find the file.

I've tried expanding the path, passing through the file_content instead of the file path, reversing the "1.mp3" with the path in terms of parameter order -- nothing seems to work here.

Client works great. Bucket I use list_buckets() and search for one by name to get the bucket object.

Any ideas?

def handle_event("submit", _params, socket) do
    uploaded_files =
      consume_uploaded_entries(socket, :audio, fn %{path: path}, _entry ->
        IO.inspect(path)
        {:ok, client} = Client.get_client()

        bucket = get_bucket_by_name(client, "audio-files")
        file_content = File.read!(path)
        expanded_path = Path.expand(path)

        IO.inspect(expanded_path)

        {:ok, audio_result} = Supabase.Storage.upload_object(client,  bucket, "1.mp3", path, %Supabase.Storage.ObjectOptions{
          cache_control: "3600",
          upsert: true
        })

        IO.inspect(audio_result)
      end)

      {:noreply, socket}
  end
@zoedsoupe
Copy link
Collaborator

interesting...

@zoedsoupe
Copy link
Collaborator

i'll try to reproduce that and do some debugging. thank you for reporting that

@slexysex
Copy link

slexysex commented Dec 7, 2024

@zoedsoupe it's caused by this line in the potion fetcher: https://github.com/supabase-community/supabase-ex/blob/b7bfe786a62f9a0ac1b5676ea4f1aa390116818b/lib/supabase/fetcher.ex#L241

I removed the utf8 encoding in a fork and uploads work for other content types: https://github.com/slexysex/supabase-ex

Unsure if this breaks other functionality as I am only using the storage api

@zoedsoupe
Copy link
Collaborator

firstly, thank you for investigating this issue, secondly, sorry for the delay in the response, i've got very busy last year and also had some time to finally transfer the libraries under the supabase-community GitHub org!

since last month i got active again and started to solve issues and implementing missing features. so i'll open a pr in the supabase-ex library to solve this! thank you again.

@zoedsoupe
Copy link
Collaborator

Fixed by the supabase-ex pull request and will be closed by #3 that updates the dependency version

@zoedsoupe zoedsoupe linked a pull request Jan 15, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants