Giter Club home page Giter Club logo

Comments (5)

jeremyjh avatar jeremyjh commented on August 29, 2024 7

arc works fine if you pass a map %{binary: <<your bytes>>, filename: "filename.txt"}. The problem in arc_ecto is cast_attachment matches the file arg against %{__struct__: Plug Upload}.

So as a workaround, you can pass:

    %{
      __struct__: Plug.Upload,
      binary: bytes,
      filename: "filename.txt"
    }

In place of an actual Plug.Upload. Ugly as sin but it works.

from arc_ecto.

yogipatel avatar yogipatel commented on August 29, 2024 4

I agree, this would be a nice feature to have. I can try to make a PR if you'd like, @stavro.

@darkbaby123 @philipgiuliani A workaround you can use for now is to write the data out to a temp file and pass that temp file's path in.

from arc_ecto.

Clyvv avatar Clyvv commented on August 29, 2024 1

Hi, im using v0.7.0 and still could not pass binary data to cast_attachments. Was this ever solved? Also I tried using Plug.Upload by creating a temp file but it seems it works at times and does not work the other times. Can someone help me out here. My function that converts my base64 to Plug.Upload is as follow
def process_image(image_base64) do {:ok, image_binary} = Base.decode64(image_base64) filename = image_binary |> image_extension() |> unique_filename() case File.write!("candidate_pics/#{filename}", image_binary, [:binary]) do :ok -> %Plug.Upload{ content_type: "image/#{image_extension(image_binary)}", filename: filename, path: Path.expand("candidate_pics/#{filename}") |> Path.absname() } {:error, reason} -> {:error, reason} end end

from arc_ecto.

jalcine avatar jalcine commented on August 29, 2024 1

Going to bump this issue and the accompanying PR #87 that fixes this.

For now, I'm just going to work off that branch until this is merged.

Nice work with the project @stavro, I know you must be busy.

from arc_ecto.

philipgiuliani avatar philipgiuliani commented on August 29, 2024

I am doing the same in my project. Version v0.5 broke this behaviour and I am not aware of a workaround. If you use version v0.5.0-rc1 or v0.4.0 everything should be fine.

@stavro Is there a way to do this now?

from arc_ecto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.