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.
%MyStruct{
thumbnail: %Plug.Upload{filename: "sample.png", path: "test/fixtures/sample.png"}
}
2 Likes
thanks, this works
Channel.changeset(%Channel{},
%{
name: "channel#{Timex.now()}",
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