Closed supercena closed 4 weeks ago
error:
{"timestamp":"2024-04-26T01:25:49.657+0000","status":500,"error":"Internal Server Error","message":"Failed to parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found","path":"/File/"}
and i have another question if i use python script to send a Chinese path file to Remote machine in tagui script , that is not ok.
try to use run
command with curl
Runs a command in Command Prompt or Terminal and saves the stdout to the variable run_result
.
run [shell command]
Examples
run cmd /c mkdir new_directory
@marcelocecin hello i use curl command on windows by tagui script as follows:
run cmd /c D:\curl-8.7.1_7-win64-mingw\curl-8.7.1_7-win64-mingw\bin\curl.exe -X POST -F "file=@D:\rpa\rpademo\tuijian\1714300843597.txt" http://localhost:8080/File/
echo run_result
errors: The filename, directory name, or volume label syntax is incorrect.
but I use curl -X POST -F "file=@D:\rpa\rpademo\tuijian\1714300843597.txt" http://localhost:8080/File/ on cmd command ,that is ok. but using tagui ,error is The filename, directory name, or volume label syntax is incorrect. why?
how to debug tagui source code?
try using command arguments with single quotes
@marcelocecin using single quotes is not ok . it is too hard to use.
so try to create tagui_local.js
example:
function send_attachment_url(msg,file,url) {
casper.options.waitTimeout = (30*1000);
casper.waitForExec('curl -F msg="'+msg+'" -F upload=@'+file+' '+url, null, function(response) {
run_result = '';
run_result = (response.data.stdout.trim() || response.data.stderr.trim()); run_result = run_result.replace(/\r\n/g,'\n');
run_json = response.data;
this.exit();},
function() {this.echo('ERROR - command to run exceeded '+(casper.options.waitTimeout/1000).toFixed(1)+'s timeout').exit();});
}
then in your script.tag
https://google.com
wait 5
js send_attachment_url("sd","C:\Users\Admin\AppData\Local\Postman\app-6.0.10\ffmpeg.dll","http://localhost:8080/File/")
PS: If it still doesn't work, I suggest testing sending it to an external url, for example https://webhook.site/
@marcelocecin thanks very much, i will try it first
I optimize and refine the syntax of my code. Here's the updated version and it works on windows. @marcelocecin thanks so much
js begin function send_attachment_url() { var fs = require('fs'); // Import the file system module var dataFilePath = 'D:\rpa\rpademo\xinniuren\历史.txt'; if (!fs.exists(dataFilePath)) { casper.echo('File does not exist: ' + dataFilePath).exit(); } if (!fs.isFile(dataFilePath)) { casper.echo('Path is not a file: ' + dataFilePath).exit(); } if (!fs.isReadable(dataFilePath)) { casper.echo('File is not readable: ' + dataFilePath).exit(); } var curlPath = 'D:/curl-8.7.1_7-win64-mingw/curl-8.7.1_7-win64-mingw/bin/curl.exe'; casper.start().waitForExec(curlPath, ["-X", "POST", "-F", "file=@" + dataFilePath.replace(/\/g, '/'), "http://localhost:8080/File/"], function(response) { this.echo(JSON.stringify(response.data)); }, function() { this.echo('Command timed out'); }, 20000); casper.run(function() { this.exit(); }); } send_attachment_url(); js finish
api_config = {method:'POST', header:['Content-type: multipart/form-data'], body:'name=sd&file=@C:\Users\Admin\AppData\Local\Postman\app-6.0.10\ffmpeg.dll'}; api http://localhost:8080/File/ echo
api_result