SFTP file upload

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Gurgen
Posts: 34
Joined: Thu Dec 10, 2015 2:09 pm

SFTP file upload

Post by Gurgen »

Hi All,

I'm trying to upload file into SFTP server using tsNetUploadFile, but with nor any result.

Here is my code

Code: Select all

local sConID

function uploadFileSFTP pFile, pHost, pUsername, pPassword
   
   add 1 to sConID
   put "sftp://" & pHost & ":22/mnt/myfolder" into tURL
   put true into tSettings["use_ssl"]
   put true into tSettings["no_reuse"]
   put true into tSettings["save_sent_headers"]
   put pUsername into tSettings["username"]
   put pPassword into tSettings["password"]
   
   put tsNetUploadFile(sConID, pFile, tURL,, "uploadDone", tSettings) into tResult

   return tResult
end uploadFileSFTP
tsNetUploadFile returns empty, which means it's OK, but not calling the callback(uploadDone). I think something is wrong with my code, please help to figure out.

Thanks,
Gurgen
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: SFTP file upload

Post by jacque »

The command also needs a callback parameter, which I don't see in your handler.

tsNetUploadFile(pConnectionID, pFile, pURL, pHeaders, pCallback, [pSettings])
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
Gurgen
Posts: 34
Joined: Thu Dec 10, 2015 2:09 pm

Re: SFTP file upload

Post by Gurgen »

jacque wrote:The command also needs a callback parameter, which I don't see in your handler.

tsNetUploadFile(pConnectionID, pFile, pURL, pHeaders, pCallback, [pSettings])
Hi Jacque,

Thank you for replay.

I set the callback parameter to "uploadDone", which to can see in the sample code. I have the handler, but tsNet never sending it, so I assume that something still wrong with my code, but callback is not the problem.

Thanks,
Gurgen
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: SFTP file upload

Post by jacque »

Yes, I see it now. I did not scroll the short view box far enough down.

What do you see when you get the LC result?

put tsNetUploadFile(sConID, pFile, tURL,, "uploadDone", tSettings) into tResult
put the result into tLResult

Also, what edition of LC are you running? There are restrictions on SFTP transactions if you are not running a business version. Does it work if you use FTP instead?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
Gurgen
Posts: 34
Joined: Thu Dec 10, 2015 2:09 pm

Re: SFTP file upload

Post by Gurgen »

jacque wrote:Yes, I see it now. I did not scroll the short view box far enough down.

What do you see when you get the LC result?

put tsNetUploadFile(sConID, pFile, tURL,, "uploadDone", tSettings) into tResult
put the result into tLResult

Also, what edition of LC are you running? There are restrictions on SFTP transactions if you are not running a business version. Does it work if you use FTP instead?
Hi Jacque,

I'm using LC 8.1.1 Business.

tResult and the result are always empty. Also I have tried with "ftp" instead of "sftp" in URL, but same result.

Thanks,
Gurgen
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: SFTP file upload

Post by jacque »

Sorry, I'm not sure what the problem is. There are a couple of example stacks for tsNet but I can't find the links. Maybe someone else has them and will post here. Otherwise I think you may need to write to support.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: SFTP file upload

Post by MaxV »

Hi all,
in the open source version tsNet is missing, but it's missing also any documentation of it; so who uses livecode open source can't know what tsNet do.
I ask you the favour to fill the end of this page: http://livecode.wikia.com/wiki/TsNet
with all information you have in your dictionaries about tsNet functions and messages.
Just click on the edit button of the page.

Best regards
Max (livecode evangelist)
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: SFTP file upload

Post by FourthWorld »

MaxV wrote:Hi all,
in the open source version tsNet is missing, but it's missing also any documentation of it; so who uses livecode open source can't know what tsNet do.
The tsNet external was written by a third party who has not made the source code available under the GPL, which would be needed for inclusion in the GPL-governed LiveCode Community Edition. Bundled under proprietary license, at this time it's only available in the proprietary editions of LiveCode.

All other networking (HTTP, HTTPS, FTP, sockets) are of course available in all editions of LiveCode, including Community.

FTP/FTPS is rarely needed, designed for providing ad hoc access to file repositories. I have one app where it's useful, but for moving data from a client app to a server a more secure and efficient means is to write a CGI for the server to receive the data over HTTP/HTTPS so it can validate the data and put it where it needs to go.

This Lesson describes how to write the CGI in LiveCode using LiveCode Server, and there are many examples on the web for writing that in PHP, Python, and other languages as well:
http://lessons.livecode.com/m/4070/l/40 ... ode-server
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
trevix
Posts: 1108
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: SFTP file upload

Post by trevix »

Do we still need a "Business license" (?) to upload to SFTP?

By the way, this page has broken links. Does it still apply?
https://livecode.com/products/livecode- ... iness-b12/
Trevix
OSX 15.7 xCode 26.01 LC 10.0.3 RC1 iOS 15> Android 7>
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: SFTP file upload

Post by Klaus »

Hi Trevix,

as far as I know the tsNet external neccessary for SFTP is only contained in the "Standard plan" (business) version.


Best

Klaus
trevix
Posts: 1108
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: SFTP file upload

Post by trevix »

Since I have a standard plan, you mean that I have a business plan?
Trevix
OSX 15.7 xCode 26.01 LC 10.0.3 RC1 iOS 15> Android 7>
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: SFTP file upload

Post by Klaus »

Puh, good question, really not sure. :D
Try this in the message box:

Code: Select all

put tsNetVersion()
I got: Version 1.4.8 Business Edition
If that does not throw an error, you have a business version.
trevix
Posts: 1108
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: SFTP file upload

Post by trevix »

Version 1.4.8 Business Edition

Thanks (Pfuiiiii)
Trevix
OSX 15.7 xCode 26.01 LC 10.0.3 RC1 iOS 15> Android 7>
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: SFTP file upload

Post by Klaus »

trevix wrote: Thu Jan 26, 2023 4:50 pm Version 1.4.8 Business Edition
Thanks (Pfuiiiii)
COOOOOL! :-)
bobcole
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 175
Joined: Tue Feb 23, 2010 10:53 pm

Re: SFTP file upload

Post by bobcole »

I tried it on my Mac:
Version 1.4.8 Indy Edition
Bob
Post Reply