Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload tutorial file path triggers live reload for images #2253

Closed
jsmestad opened this issue Oct 3, 2022 · 4 comments · Fixed by phoenixframework/phoenix#5702
Closed

Upload tutorial file path triggers live reload for images #2253

jsmestad opened this issue Oct 3, 2022 · 4 comments · Fixed by phoenixframework/phoenix#5702

Comments

@jsmestad
Copy link
Contributor

jsmestad commented Oct 3, 2022

Background

While trying to implement LiveView uploads I was pulling my hair out because the Plug.Upload file kept disappearing.

I could not figure out the cause until it hit me: the default live_reload config uses priv/static/*.(png|jpg|....) which is the same save location used by the Upload tutorial.

What happens

Whenever the file is copied into the path this triggers a recompilation due to the live_reload pattern match and thus reaping the current process and the Plug.Upload path goes missing.

Suggested Change

Most folks are probably testing this with image files, so I'd suggest using an alternative path in the tutorial. Since the path makes sense though, we could also add a disclaimer in the tutorial. I really wasn't sure which is least disruptive.

@jsmestad jsmestad changed the title Change Upload filepath to avoid tail chasing Upload tutorial file path triggers live reload for images Oct 3, 2022
@chrismccord
Copy link
Member

This is a tricky one because the shortest path to serving the files that were uploaded is to put them into priv/static, so they can be picked up by the Plug.Static. The alternative is to place them own something like priv/uploads, then add another Plug.Static definition, or update the live reload patterns in the guide to ignore the uploads dir. The latter gets my vote. Can you send a PR? Thanks!

@chrismccord
Copy link
Member

Ping @jsmestad any interest in sending PR to the guides? Thanks!

@jsmestad
Copy link
Contributor Author

jsmestad commented Dec 5, 2022

@chrismccord definitely interested in contributing when I can find the time. Crunch time getting HeadsDown out the door 🔥

@josevalim
Copy link
Member

This is tricky because we want to add them to priv/static so we can render them :S

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants