InsertFromURL PUSH FTP

Is there an example how to specify an InsertFromURL call to succeed connecting to an FTP server and uploading a file to a directory (so that it works)? And of course the cURL options!!!

Assuming you have the ftp server's URL and you have an account to acceess and you have a file in a container field. Somehow I cannot find any instructions how to conduct this successfully!

1 Like

I've done it. I think you should be able to find the info you need here: Claris Community (English)

tl;dr

$curl

--upload-file $file --user "<USERNAME>:<PASSWORD>"

$url

ftp://my.server.com/my-cool-file.txt

$file (can be text or container data)

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non nibh at neque vehicula accumsan quis hendrerit ligula. Integer vestibulum justo dolor, sit amet maximus mi euismod sed.

FM Script

Insert From URL [ Target: $result ; $url ; cURL options: $curl ]

Full Example

# Plop container field data into a var so it's plopped and ready to go.
Set Variable [ $file ; Value: Table::container_to_upload ] 
# Then reference the var *name* in the curl calc (don't substitute it in).
Set Variable [ $curl ; Value: "--upload-file $file --user \"josh:josh\" --dump-header $response_headers --trace-ascii $trace" ] 
# ftp server running on localhost for testing.
# Picking a random uuid filename for this  example:
Set Variable [ $url ; Value: "ftp://localhost/uploads/" & Get ( UUID ) & ".png" ] 
Insert from URL [ Select ; With dialog: Off ; Target: $response_body ; $url ; cURL options: $curl ] 

# Store result (body probably empty, and the headers/trace optional)
Set Field [ Table::response_body ; $response_body ] 
Set Field [ Table::response_headers ; $response_headers ] 
Set Field [ Table::trace ; $trace ] 
Commit Records/Requests [ With dialog: Off ] 
1 Like

Anyone have a SFTP version?

2 Likes

I've gotten mixed messages about whether sftp works from FM. I'm assuming the above doesn't work for sftp:// for you then?

Mr camelCase said it works for him here: Claris Community (English)

1 Like

he is also a member of the forums here: @CamelCase

1 Like

Thank you very much @jwilling !