Giter VIP home page Giter VIP logo

Comments (10)

supercena avatar supercena commented on July 22, 2024 1

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

from tagui.

supercena avatar supercena commented on July 22, 2024

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/"}

from tagui.

supercena avatar supercena commented on July 22, 2024

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.

from tagui.

marcelocecin avatar marcelocecin commented on July 22, 2024

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

from tagui.

supercena avatar supercena commented on July 22, 2024

@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?

from tagui.

supercena avatar supercena commented on July 22, 2024

how to debug tagui source code?

from tagui.

marcelocecin avatar marcelocecin commented on July 22, 2024

try using command arguments with single quotes

from tagui.

supercena avatar supercena commented on July 22, 2024

@marcelocecin using single quotes is not ok . it is too hard to use.

from tagui.

marcelocecin avatar marcelocecin commented on July 22, 2024

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/

from tagui.

supercena avatar supercena commented on July 22, 2024

@marcelocecin thanks very much, i will try it first

from tagui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.