it would be great if command
Code: Select all
/tool/fetch http-method=post url="https://blabla.server/fileservice" mode=https
Better without that annoying 4kB limitation!
May I believe in that it will be implemented?
/tool/fetch http-method=post url="https://blabla.server/fileservice" mode=https
:set $data "up to 63KB..."
/tool fetch http-method=post http-content-type="application/json" http-data=$data url="https://testserver.lv/index.php"
Thank youA few months ago no one knew that chunking was possible in combination with variable in ROS and now it used widely.
:global $data "test";
:global $url "https://prod-51.westeurope.logic.azure.com:443/workflows/blabla/triggers/manual/paths/invoke....";
/tool fetch mode=https http-method=put http-data=$data url=$url
{
"headers": {
"User-Agent": "Mikrotik/7.x,Fetch",
"Content-Type": "application/x-www-form-urlencoded"
},
"body": {
"$content-type": "application/x-www-form-urlencoded",
"$content": "dGVzdA==",
"$formdata": [
{
"key": "test",
"value": ""
}
]
}
}
/export file=export.rsc
:global data [/file get [/file find name=export.rsc] contents];
this is example for "file download" and using chunks.It is the first code example in this tread: viewtopic.php?f=9&t=177530
/tool/fetch
Please, lets focus here on how to anyhow send any file from mikrotik to remote HTTP server. (not vice versa, etc.)
:global filedata [/file get myfile contents]
:put $filedata
Look I ain't arguing you ROS shouldn't support some "file upload". All I was saying "file upload" can happen in a variety of ways (form-data, WebDAV, etc.) – so it's not as simple as a missing "files=" min fetch.@Amm0
https://help.mikrotik.com/docs/display/ ... -Variables
> Note: Variable value size is limited to 4096bytes
https://help.mikrotik.com/docs/display/ROS/Fetch
/export file=export.rsc
:global data [/file get [/file find name=export.rsc] contents];
:global $url "https://prod-51.westeurope.logic.azure. ... ths/invoke....";
/tool fetch mode=https http-method=put http-data=$data url=$url
Dear Mikrotik forums,
it would be great if commandcan specify the file on mikrotik that will be send as data of POST request.Code: Select all/tool/fetch http-method=post url="https://blabla.server/fileservice" mode=https
Better without that annoying 4kB limitation!
May I believe in that it will be implemented?
+1 for this featureDear Mikrotik forums,
it would be great if commandcan specify the file on mikrotik that will be send as data of POST request.Code: Select all/tool/fetch http-method=post url="https://blabla.server/fileservice" mode=https
Better without that annoying 4kB limitation!
May I believe in that it will be implemented?
+1 for this featureDear Mikrotik forums,
it would be great if commandcan specify the file on mikrotik that will be send as data of POST request.Code: Select all/tool/fetch http-method=post url="https://blabla.server/fileservice" mode=https
Better without that annoying 4kB limitation!
May I believe in that it will be implemented?
:global sendFormDataFile do={
:local urlf $url
:local formFieldName $field
:local fileName $file
:local mimeSeperator "--$[:rndstr]"
:local contentType "Content-Type: multipart/form-data; boundary=$mimeSeperator"
:local fileMimeType "application/octet-stream"
:local formdataMime "\
$mimeSeperator\n\
Content-Disposition: form-data; name=\"$formFieldName\"; filename=\"$formName\"\n\
Content-Type: $fileMimeType\n\
Content-Transfer-Encoding: base64\n\n\
$[:convert from=raw to=base64 [/file/get $fileName content]]\n\n\
$mimeSeperator--\n"
/tool/fetch http-method=post url=$urlf http-header-field=$contentType http-data=$formdataMime output=user
}
$sendFormDataFile url="http://192.168.88.1:80/upload" file=myrouterfile field=formfieldname
https://api.telegram.org/bot5955340922:AAE4Ljtk4Gm8anV8QoXhgck11CdNLCUaz1M/sendDocument\?chat_id=340234876
And backup files are normally bigger than 64kB (and even bigger when base64-encoded for form-data).In sendDocument, sending by URL will currently only work for GIF, PDF and ZIP files.
/tool fetch address=$ftpserver mode=ftp user=$username password=$password \
src-path=$backupfilename dst-path=$backupfilename upload=yes port=$port;