Phoenix seeds.exs using cast_attachments?

I am having problems finding an example of seeds.exs for Phoenix that uses cast_attachments.

I want to create seeds for Waffle Ecto and upload a random image in each seed.

I guess this is equivalent to use Plug.Upload in a seeds.exs

I assume it’s possible, pointers or suggestions welcome.

Yes it is possible…

I do something like this.

  thumbnail: %Plug.Upload{filename: "sample.png", path: "test/fixtures/sample.png"}

thanks, this works

  name: "channel#{}",
  owner_id: "1",
  banner: %Plug.Upload{content_type: "image/jpg", filename: "florida-storm.jpg", path: "test/convert/florida-storm.jpg"},
  website_id: "2"
|> Repo.insert!
1 Like