Tech Tip: Options for transferring large files
PRODUCT: 4D | VERSION: 2004 | PLATFORM: Mac & Win
Published On: May 31, 2007
It is very common to need to transfer large files around your local filesystem or even to other machines. With 4D there are several ways to accomplish this task depending upon your needs and operating system.
LAUNCH EXTERNAL PROCESS
The LAUNCH EXTERNAL PROCESS command allows you to launch an external process from 4th Dimension under Mac OS X and Windows.
To move around large files on your local file system you could use something similar to the following:
As an example to copy (MacOS):
LAUNCH EXTERNAL PROCESS("cp /path/to/source/file /path/to/target/file") |
As an example to copy (Windows):
LAUNCH EXTERNAL PROCESS("copy /path/to/source/file /path/to/target/file") |
As an example to move (MacOS):
LAUNCH EXTERNAL PROCESS("mv /path/to/source/file /path/to/target/file") |
As an example to move (Windows):
LAUNCH EXTERNAL PROCESS("move /path/to/source/file /path/to/target/file") |
As an example to delete (MacOS):
LAUNCH EXTERNAL PROCESS("rm /path/to/target/file") |
As an example to delete (Windows):
LAUNCH EXTERNAL PROCESS("del /path/to/target/file") |
To move around large files on remote systems you could use something similar to the following:
As an example to copy (MacOS):
LAUNCH EXTERNAL PROCESS("scp localfile username@ftp.4d.com:.") |
(Please notice the '.' at the end of the command. This is not a mistake, it is required! See the scp man page.)
In order to achieve the 'scp' functionality on Windows, a third party utility is needed as Windows does not come with 'scp' built in by default.
To move around large files on remote systems you could use something similar to the following:
As an example to FTP (MacOS and Windows):
LAUNCH EXTERNAL PROCESS("ftp ftp://user:password@host/path") |
The above options all provide ways to transfer files around. One last very attractive method is using 'cURL' with LAUNCH EXTERNAL PROCESS. cURL is a command line tool for transferring files with URL syntax, supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, FILE and LDAP. cURL supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user/password authentication (Basic, Digest, NTLM, Negotiate, kerberos...), file transfer resume, proxy tunneling, etc. For more information, please visit the cURL homepage at:
https://curl.haxx.se/docs/manpage.html
There is a Tech Note that uses cURL to handle HTTP:
https://www.4d.com/knowledgebase?CaseID=37215
You can also use the 4D Internet Commands plug-in for FTP:
https://www.4d.com/docs/ICU/ICU00006.HTM