Search code examples
elixirphoenix-framework

Take a fs path as a param in phoenix


So i want a route that can take a fs path as a parameter like this: GET "/test/*fs_path", FsController, :fsc this pattern that i used here: *fs_path does match fs paths however it just deletes all / characters from the actual fs_path so a request like this: GET /test/directory/file.json will give fs_path the following value: directoryfile.json.


Solution

  • It is extremely hard to tell what are you doing wrong without you showing the code, bus assuming you have "/test/*fs_path" in your router handled by SomeController.test/2 callback, the second argument to this function (named params) would contain

    %{"test" => ["directory", "file.json"]}
    

    and you might concatenate it back then with Path.join/1 or something.