on 01-27-2017 7:58 AM
I want to upload a csv file to HANA through XSJS.
My FileUploader
definition in my .xml
file:
<u:FileUploader
id="fileUploader"
name="myFileUpload"
uploadUrl="service/upload_csv.xsjs"
width="280px"
placeholder="Upload your CSV file"
tooltip="Upload your csv file to define the threshold"
uploadComplete="handleUploadComplete"/>
<Button
text="Upload File"
press="handleUploadPress"/>
The definition of handleUploadPress
in my .js
file:
handleUploadPress : function(event) {
var fileLoader = this.byId("fileUploader");
fileLoader.upload();
}
The response of upload_csv.xsjs
:
Request execution failed due to missing or invalid XSRF token
What can I do to solve this issue? I already tried some other example available on the internet, but always end up with this error. Even if I try to manually request the XSRF token and send a manual request to the xsjs service.
I guess you have configured following in the .xsaccess file:
"prevent_xsrf" : true,
This activated security feature will require a XSRF token in the header of any request, which does not have the request method GET or HEAD.
As deactivating security features is unwise, you could use a third party library like Papa Parse to parse the CSV on the client side and submit the parsed data to the XSJS file as AJAX call with a JSON body including the required header. Such a workaround is anyway safer than uploading files to a server where you would have to run antivirus scans and so on.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.