简体   繁体   中英

Error when trying to open a file inside a docker with Elixir

I'm inside a docker, running a test and trying to open a file using File.open .

This is my test code:

upload = %Plug.Upload{
        filename: "funcionarios.csv",
        path: Path.expand("/home/company/code/project/apps/project_web/test/project_2/resolver/funcionarios.csv", __DIR__)
      }

This is the error I get:

** (File.Error) could not open "/home/company/code/project/apps/project_web/test/project_2/resolver/funcionarios.csv": no such file or directory

What am I doing wrong?

The problem is that I run my code inside a container and I was passing the local path not the container path.

Using the Path.expand it converts the path to an absolute one.

The correct code is:

upload = %Plug.Upload{
        filename: "funcionarios.csv",
        path: Path.expand("funcionarios.csv", __DIR__)
      }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM