supabase-community / storage-ex

Elixir client to interact with Supabase Storage
https://hexdocs.pm/supabase_storage
MIT License
3 stars 1 forks source link

Invalid Unicode Upload from Liveview Upload? #2

Open rhh4x0r opened 1 month ago

rhh4x0r commented 1 month ago

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 commented 1 month ago

interesting...

zoedsoupe commented 1 month ago

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