Closed loongmxbt closed 8 years ago
Try this:
backend = Exfile.Config.get_backend("store")
{:ok, file} = Exfile.Backend.upload(backend, %Exfile.LocalFile{path: "path/to/file/on/local/computer"})
Repo.delete_all Paper
Paper.changeset(%Paper{}, %{title: "paper title", topic_id: 1, user_id: 1, file: file})
|> Repo.insert
There's a convenience function in Exfile.BackendTest
to upload a string in to a file:
backend = Exfile.Config.get_backend("store")
{:ok, file} = Exfile.BackendTest.upload_string(backend, "string with contents of file")
Thanks a lot! Exfile.BackendTest
helps a lot!
Sorry for the confusion, and thanks for the reminder. I'll be adding a testing section to the readme in #34 😄
Here I want to add a record
Paper
which contains a Exfile.Ecto.File, is there a quick way to upload a file viaseeds.exs
? Or what is the valid fileUrl? Thanks!