miyako/4d-plugin-curl-v3

PDF File Transfer to SFTP Server

Closed this issue · 5 comments

I'm trying to do a PDF file upload to a SFTP server with 4D Server v15.5 (64-bit) but am encountering some issues.

Hope you can advise on where I have gone wrong…

For the purpose of testing, I have downloaded and run Rebex Tiny SFTP Server.

I have downloaded your 4d-plugin-curl-v3 from Github and placed the cURL bundle in the plugins folder of 4D Server.

When the test script is run on the server, I hit an error on at the line …$error:=cURL($options;$request;$response;$callback;$transferInfo;$headerInfo)

The 4D syntax error is a “operation not compatible with the two arguments” between the $request and $response variables.

This is the 4D script I am testing…

If (Test path name($path)=Is a document)
C_OBJECT($options)

OB SET($options;“URL”;$vt_remote)
$options.SSL_VERIFYPEER:=0
$options.SSL_VERIFYHOST:=0
$options.UPLOAD:=1
$ptions.USERNAME:=“tester”
$options.PASSWORD:=“password”
$options.PRIVATE:=String($progressId)vr_DocSize:=Get document size($path)

$vr_filesize:=(vr_DocSize/1000)/1000
Case of
: ($vr_filesize>10)
OB SET($options;“UPLOAD_BUFFERSIZE”;2000000)
: ($vr_filesize>5)
OB SET($options;“UPLOAD_BUFFERSIZE”;1000000)
: ($vr_filesize>2)
OB SET($options;“UPLOAD_BUFFERSIZE”;500000)
End case

SET BLOB SIZE($request;0)
SET BLOB SIZE($response;0)
DOCUMENT TO BLOB($path;$request)

$error:=cURL($options;$request;$response;”";$transferInfo;$headerInfo)

If (BLOB size($response)>0)
$returntxt:=Convert to text($response;“utf-8”)
End if

End if

For what it's worth, I have tried using v2 of the plugin with the code line changed to ...
$error:=cURL(JSON Stringify($options);$request;$response;”";$transferInfo;$headerInfo)
....and encountered the same compatibility syntax error.

Beyond this basic script, are there any other specific command lines I need to add to connect successfully to a sFTP server and upload files to them one way?

Thanks you, Miyako

”"

the first character is not double quote.

same with

OB SET($options; “UPLOAD_BUFFERSIZE”; 2000000)
OB SET($options; “UPLOAD_BUFFERSIZE”; 1000000)
OB SET($options; “UPLOAD_BUFFERSIZE”; 500000)

and

``4d
$ptions.USERNAME:=“tester”
$options.PASSWORD:=“password”


and 

```4d
OB SET($options; “URL”; $vt_remote)

also missing "o" in "ptions"

please be more considerate when you post code.

Hi Miyako,

The missing character is an oversight on my part, my apologies for it.

I don't get what you mean by "the first character is not double quote" .......will try to figure it out though.
Thank you.

if you copy and paste from your own post you would see that it is a different character.

you must have used an editor that auto corrects parentheses.

Hi Miyako,
This is the exact script pasted from 4D. When run under v3, it creates the compatibility syntax error between $request and $response on the line ....
$error:=cURL($options;$request;$response;"";$transferInfo;$headerInfo)

// Start 4D Code
$path:=[Procedures]PDF_FullPath
$vt_remote:="sftp://localhost:2222/Test.pdf"

If (Test path name($path)=Is a document)
C_OBJECT($options)
OB SET($options;"URL";$vt_remote)
$options.SSL_VERIFYPEER:=0
$options.SSL_VERIFYHOST:=0
$options.UPLOAD:=1
$options.USERNAME:="tester"
$options.PASSWORD:="password"

vr_DocSize:=Get document size($path)
$vr_filesize:=(vr_DocSize/1000)/1000
Case of
: ($vr_filesize>10)
OB SET($options;"UPLOAD_BUFFERSIZE";2000000)
: ($vr_filesize>5)
OB SET($options;"UPLOAD_BUFFERSIZE";1000000)
: ($vr_filesize>2)
OB SET($options;"UPLOAD_BUFFERSIZE";500000)
End case
C_BLOB($request;$response)
C_TEXT($transferInfo;$headerInfo)
SET BLOB SIZE($request;0)
SET BLOB SIZE($response;0)
DOCUMENT TO BLOB($path;$request)

$error:=cURL($options;$request;$response;"";$transferInfo;$headerInfo)

If (BLOB size($response)>0)
$returntxt:=Convert to text($response;"utf-8")
End if
End if

// End 4D Code

just do

$error:=cURL($options; $request; $response; "")

transfer info is included in the return value.

you could have easily found this if you used the sample project.