social-post | Library helping you publish status updates | Portal library
kandi X-RAY | social-post Summary
kandi X-RAY | social-post Summary
Library helping you publish status updates on Facebook, LinkedIn and Twitter in centralised way.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Prepares share options .
- Prepare message parameters .
- Publish a message .
- Prepare message status .
- Set the list of networks to publish on .
- Can this message be published
- Returns the list of networks to publish on .
- Get the error message
social-post Key Features
social-post Examples and Code Snippets
Community Discussions
Trending Discussions on social-post
QUESTION
I have a form in a Phoenix LiveView that contains a file_input
. I want to use it to allow a user to upload an image. I'm having trouble understanding what the form is sending to my backend, and what I can do with it. I expected a %Plug.Upload{} representation of the image file, as described in documentation, but instead I just get "[object File]"
.
Note that I am not backing the form with a changeset, because I am not using Ecto:
...ANSWER
Answered 2020-Jan-16 at 01:43As @sbacaro pointed out, file uploads are not yet supported in LiveView forms.
More info on this:
- https://github.com/phoenixframework/phoenix_live_view/issues/104
- https://elixirforum.com/t/elixirconf-2019-how-liveview-handles-file-uploads-gary-rennie/25092
I implemented a Javascript workaround to manually send the form without refreshing the page (so that other parts of the LiveView an continue to function normally).
But were also issues with the way Phoenix handled CSRF tokens in LiveViews. It turns out the LiveView creates a new token when the socket connects from the client, and this token won't be recognized by controllers listening to POSTs from the form. To workaround this you need to manually pass the token into the LiveView.
Overall, this workaround works fine, but I hope that someday in the future someone will point out here that file uploads have achieved support in LiveViews and share an easier way.
My form now looks like this. Note the manual specification of the csrf token:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install social-post
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page