stavro / arc

:paperclip: Flexible file upload and attachment library for Elixir
1.16k stars 210 forks source link

Local upload - (UndefinedFunctionError) function nil.id/0 is undefined #299

Closed conradwt closed 3 years ago

conradwt commented 3 years ago

Hi, I followed all the configuration listed in the README.md file. However, when I attempt to upload the file locally, I'm getting nil.id/0 message, and the application terminates. BTW, the below error is referencing the following line of code:

  def filename(version, {file, scope}) do
    file_name = Path.basename(file.file_name, Path.extname(file.file_name))
    "#{scope.id}_#{version}_#{file_name}" # issue appears to be here
  end

Environment

Expected behavior

I would expect that my image uploads locally without error.

Actual behavior

[error] Ranch protocol #PID<0.663.0> of listener FlixWeb.Endpoint.HTTP (connection #PID<0.621.0>, stream id 13) terminated
an exception was raised:
    ** (UndefinedFunctionError) function nil.id/0 is undefined
        nil.id()
        (flix 0.1.0) lib/flix_web/uploaders/main_image.ex:43: Flix.MainImage.filename/2
        (arc 0.11.0) lib/arc/definition/versioning.ex:10: Arc.Definition.Versioning.resolve_file_name/3
        (arc 0.11.0) lib/arc/actions/store.ex:81: Arc.Actions.Store.put_version/3
        (elixir 1.11.4) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
        (elixir 1.11.4) lib/task/supervised.ex:35: Task.Supervised.reply/5
        (stdlib 3.14.1) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
achempion commented 3 years ago

Here is the solution https://hexdocs.pm/waffle_ecto/filepath-with-id.html.

conradwt commented 3 years ago

@achempion Thanks for the information but I'm going to move to Waffle at this time and give it a go. Thus, I'm going to close this issue.