INNOV-AI

Innovation and Research from Réunion Island, France

Back   Home

Upload file from remote connection @ CONNECT - Connections @ MentDB Weak

> Start the server
> (or start the server for the first time (embedded mode - H2 Database))
> (or start the server for the first time (remote mode - MySQL 8 Database))
> Open the MentDB Weak Editor

Click on 'CONNECT' tab, open 'Remote file', right click on 'demo_cm_ftp' and select 'UPLOAD FILES'

MQL INPUT
script create post "demo.file.ftp.upload" false 1 
  (param
  	(var "[localDirectory]" {true} "The local directory" is_null:false is_empty:false "/Users/jimmitry/Desktop/ftp")
  	(var "[filter]" {true} "The file filter from the remote directory" is_null:false is_empty:false ".*png")
  	(var "[remoteDirectory]" {true} "The remote directory" is_null:false is_empty:false "/Users/jimmitry/Desktop")
  ;) 
  "Upload file through FTP" 
{

	try {

		#Connect to the FTP server;
		ftp connect "session1" {cm get "demo_cm_ftp";};
		ftp set type "session1" "BINARY";

		#Move to the remote directory;
		ftp cd "session1" [remoteDirectory];

		#Get all local files;
		json load "files" (file dir_list_regex [localDirectory] [filter] true true);

		#Put all files;
		-> "[nbFiles]" (json count "files" "/");
		for (-> "[i]" 0) (< [i] [nbFiles]) (++ "[i]") {

			-> "[filename]" (json select "files" (concat "/[" [i] "]"));
		
			ftp put "session1" (concat [localDirectory] "/" [filename]) "RESUME";
		
		};

		ftp disconnect "session1";
	
	} {
	
		#Close objects;
		try {ftp disconnect "session1";} {} "[sub_err]";

		#Generate an error;
		exception (1) ([err]);
	
	} "[err]";
	
	
} "Return nothing";
start: 2026-01-17   end: 2026-01-31   v_start: 401   v_end: