Reduce this list to just the path names ie ["c:\\filepath", "c:\\filepath"]
Save both of those files to a local disk.
Update the struct to be saved to the db with the list of the new, saved filepaths ie Map.update(%Struct, :images, ["c:\\filepath", "c:\\filepath"], &1)
For a single item you would just File.cp("source.path", "local.path"), which is easy enough with just one %Plug.Upload{} struct, but I struggle with writing the enum functions and iterating over each item to do things. Can anyone be of assistance?
Thank you!
One little tweak, the path that it gives you is the actual file so there’s no need for filepath = path <> filename.
Otherwise this is exactly what I was looking for and I think I understand Enum.map a little better. I was thinking I would have to do an Enum.each as well but I see map does that for you. I really appreciate it.
each when you don’t want to get the results, but are just doing it for side effects–rarer in functional-style programming, but possible, because after all you might be putting things into a db, or printing them for debugging, or… moving files into a new location
reduce when you want to collect something more complicated than a simple list of results–this one is the most general, you can (maybe should) think of the others as shorthand for common uses of reduce