Passing file in POST when starting the application
Added by Islam Abdalla about 9 years ago
Hello everyone,
I am creating a project that on receives a file on startup via POST request. The post request can come from third party. Encryption type is multipart/form-data. The request first goes to WResourse to handle the uploaded file and the start the application by passing the file location on the approot.
I am having some problems implementing this logic.
- How to start an application from WResource?
- If not possible, my second option (I think) is to use WEnvironment to recieve the post. But then how to access the uploaded file in WEnvironmet? it doensn't have getUploadedFile() method.
Replies (5)
RE: Passing file in POST when starting the application - Added by Wim Dumon about 9 years ago
Maybe it works if you send a HTTP redirect response to the file upload to the Wt application URL?
Wim.
RE: Passing file in POST when starting the application - Added by Islam Abdalla about 9 years ago
Hi,
Thank you very much. In fact, that's exactly what I've done. I sent a response with 300 status and a header location :D
RE: Passing file in POST when starting the application - Added by Mark Petryk about 9 years ago
Islam, would you mind sharing your code how you did this?
RE: Passing file in POST when starting the application - Added by Islam Abdalla about 9 years ago
Sure.
For redirection, I am setting the status to 300, and adding a Location header, from within WResource handleRequest() function. Like this,
response.setStatus(300);
response.addHeader("Location","http://localhost:8060/schem");
RE: Passing file in POST when starting the application - Added by Mark Petryk about 9 years ago
Perfect!
Thank you, sir.
~mark