Wappler provides a default API Action module in Server Action to call APIs. But it does not have the option to upload files. With this custom module, we extend Wappler to have this option as well. We have provided as many options we could from the original component here. This module is available for both PHP & NodeJS server models.
For NodeJS, you will have to install two packages - node-fetch & form-data.
For details on how to integrate custom modules in your Wappler project, please refer the help doc here.
The repository comes with a bunch of examples on how this library can be used.
Feel free to reports bugs or improvements or feature requests.
This is our first time releasing an Open Source Git repository - if you have any critical feedback we’d be happy to hear.
Hi, thnks for share! this is very useful!. I think may be @George can incorporate this to the core of Wappler? Since I have seen that it is a highly requested functionality in the community.
Thanks for the feedback.
I remember having this discussion with Patrick a long time ago. There was a compatibility issue with ASP .NET… And all components at that time were common among all server models. Now that we see some server specific components (like sockets), this could also get added.
But, it would be wise to wait for some time to iron out any issues community finds with this.
It would provide better visibility if you add the docs to the readme.md file so you don’t have to download and run the full project in order to understand all the possibilities as explained in the examples.
Thanks for the input. We did not realise this until after a few days… and then just couldn’t get to it.
Will try to add a readme asap to all the extensions.
Looks like a response body issue.
The Azure API most likely worked.
Is there way for you to verify is the request went through in the Azure portal?
Also, what is the response type of this request? Most likely its not JSON, which is the only thing supported right now, hence the error from the custom library - that it cannot understand the response received from the Azue API.
You can modify the library itself to handle the different type of response.
I don’t know how could I verify the request in the Azure portal. I know it has been sent because it shows the error in the form recognizer activity log but I can’t get more than the information shown above.
Having issues getting this beast to work… I get the following error. Any thoughts on this?
Tried to copy the files into an existing project so not sure if somethings missing.
Cheers!
{“status”:“500”,“message”:“Cannot use import statement outside a module”,“stack”:"/Users/robbydiederich/shipping box calculator/extensions/server_connect/modules/FileUploadModule.js:3\nimport FormData from “form-data”;\n^^^^^^\n\nSyntaxError: Cannot use import statement outside a module\n at Object.compileFunction (node:vm:352:18)\n at wrapSafe (node:internal/modules/cjs/loader:1026:15)\n at Module._compile (node:internal/modules/cjs/loader:1061:27)\n at Object.Module._extensions…js (node:internal/modules/cjs/loader:1149:10)\n at Module.load (node:internal/modules/cjs/loader:975:32)\n at Function.Module._load (node:internal/modules/cjs/loader:822:12)\n at Module.require (node:internal/modules/cjs/loader:999:19)\n at require (node:internal/modules/cjs/helpers:102:18)\n at App._exec (/Users/robbydiederich/shipping box calculator/lib/core/app.js:467:30)\n at App._exec (/Users/robbydiederich/shipping box calculator/lib/core/app.js:452:28)"}
Hi.
There is no import statement in the extension, only require. Have you made any changes to the FileUploadModule.js file?
Also, just to sure, check if your package.json file has required packages listed - node-fetch & form-data.
This is the error I have been getting otherwise about an ESM Module
{“status”:“500”,“code”:“ERR_REQUIRE_ESM”,“message”:“require() of ES Module /Users/robbydiederich/shipping box calculator/node_modules/node-fetch/src/index.js from /Users/robbydiederich/shipping box calculator/extensions/server_connect/modules/FileUploadModule.js not supported.\nInstead change the require of index.js in /Users/robbydiederich/shipping box calculator/extensions/server_connect/modules/FileUploadModule.js to a dynamic import() which is available in all CommonJS modules.”,“stack”:“Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/robbydiederich/shipping box calculator/node_modules/node-fetch/src/index.js from /Users/robbydiederich/shipping box calculator/extensions/server_connect/modules/FileUploadModule.js not supported.\nInstead change the require of index.js in /Users/robbydiederich/shipping box calculator/extensions/server_connect/modules/FileUploadModule.js to a dynamic import() which is available in all CommonJS modules.\n at Object. (/Users/robbydiederich/shipping box calculator/extensions/server_connect/modules/FileUploadModule.js:2:15)\n at App._exec (/Users/robbydiederich/shipping box calculator/lib/core/app.js:467:30)\n at App._exec (/Users/robbydiederich/shipping box calculator/lib/core/app.js:452:28)\n at async App.exec (/Users/robbydiederich/shipping box calculator/lib/core/app.js:421:9)\n at async App.define (/Users/robbydiederich/shipping box calculator/lib/core/app.js:411:9)”}
Having difficulty installing the extension. PHP server model and I downloaded “FileUploadModule.php” and installed it in the extensions modules folder. But when I then go search for it in the Extension section in Wappler, it does not appear. Is there any other configuration/installation I have to do?