UPLOAD_HTTP_PARAMS Map Returns empty for Custom HTTP Parameters During File Upload
Posted: 18 Dec 2024, 15:52
I am implementing file upload on the server using SmartFoxServer. I need to send additional parameters in the HTTP POST request and retrieve them server-side using the SFSEventParam.UPLOAD_HTTP_PARAMS map.
On the client side, I am sending the data like this:
On the server side, my code to retrieve the additional parameters is as follows:
However, the log outputs:
This means that the additional parameters sent from the client are not being recognized server-side.
I would like to know how to correctly pass custom parameters with file uploads and have them properly recognized by SmartFoxServer.
Thanks in advance for any help!
On the client side, I am sending the data like this:
Code: Select all
const formData = new FormData();
formData.append('sessHashId', sessHashId);
formData.append('fileName', fileName);
formData.append('__tipo', 'avatar'); // Custom parameter with double underscoreOn the server side, my code to retrieve the additional parameters is as follows:
Code: Select all
@SuppressWarnings("unchecked")
Map<String, String> httpParams = (Map<String, String>) event.getParameter(SFSEventParam.UPLOAD_HTTP_PARAMS);
trace("HTTP Params: " + (httpParams != null ? httpParams.toString() : "null"));However, the log outputs:
Code: Select all
HTTP Params:{}
This means that the additional parameters sent from the client are not being recognized server-side.
I would like to know how to correctly pass custom parameters with file uploads and have them properly recognized by SmartFoxServer.
Thanks in advance for any help!