Skip to content

Invalid Unicode Upload from Liveview Upload? #2

@rhh4x0r

Description

@rhh4x0r

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions