-
Notifications
You must be signed in to change notification settings - Fork 114
FetchJSON / FetchHydra providers don't support file uploads #31
Comments
@nonsintetic Did you figure out this by any chance? |
@rokmy it does, but you essentially have to write your own data provider for that to work. You could use the Laravel provider and adapt it for json/hydra APIs for example, the principle is the same (using FormData to support file attachments and sending that with Fetch to the server). If I do get around to writing a better provider I'll be sure to submit a pull request, I seem to be using VA for a lot of things these days. Due to time crunch and only needing it for a single thing, I just wrote a separate method to upload that particular file at the moment. |
Would you be able to share the code snipper for the upload? The thing I'm working on now, is modifying the hydra provider (hydra.js)
but the upload payload seems to be empty. |
Regarding your example, |
Thanks so much, I've modified hydra.js file to make it more dynamic, and it seems to be working for the specific use case. I will make some case switch statements later on.
Thanks so much for the help! |
When using the FetchJSON or FetchHydra (which mostly inherits from it) providers there is no support for file uploads.
These providers use JSON.stringify() to get form data and send the result to the server using HTTP Fetch. This results in request bodies such as
{ file: {} }
when using a va-file-input field in a create/edit form.In opposition, the Laravel provider uses FormData which does seem to support file uploads.
The text was updated successfully, but these errors were encountered: