It is currently Sat Dec 05, 2020 3:29 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: FTPS (windows needs additional files)
PostPosted: Sun Nov 22, 2020 7:31 pm 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5076
Location: Germany
Hi,

for this example you need for windows:

libcurl.dll
libcrypto-1_1.dll
libssl-1_1.dll

From:
https://curl.haxx.se/windows/

curl for XX bit

and below
OpenSSL

Or simply use my zip file:
https://www.von-der-salierburg.de/downl ... urldll.zip


for linux:
nothing todo, since the full libcurl.so is installed and PB uses this 'full' lib.

for OSX:
no idea, but I think it behaves like linux.


Code:
; FTPS
;
; https://curl.se/libcurl/c/ftpsget.html
;

EnableExplicit

#LibCurl_DLL$ = "libcurl.dll"

IncludeFile "libcurl.pbi"


Structure FtpFileStructure
  filename$
  file.i
EndStructure


ProcedureC.l my_fwrite(*buffer, Size, NMemB, *out.FtpFileStructure)
 
  Protected Result.i
 
 
  If Not *out\file
    *out\file = CreateFile(#PB_Any, *out\filename$)
    If Not *out\file
      Result = -1
    EndIf
  EndIf
 
  If Result = 0
    Result = WriteData(*out\file, *buffer, (Size & 255) * NMemB)
  EndIf
 
  ProcedureReturn Result
 
EndProcedure



Define curl.i, ftpfile.FtpFileStructure, res.i


InitNetwork()

curl_global_init(#CURL_GLOBAL_DEFAULT)

curl = curl_easy_init()
If curl
 
  ftpfile\filename$ = GetPathPart(ProgramFilename()) + "file.txt"
 
  curl_easy_setopt_str(curl, #CURLOPT_URL, "ftps://user@server/home/user/file.txt")
 
  curl_easy_setopt(curl, #CURLOPT_WRITEFUNCTION, @my_fwrite())
  curl_easy_setopt(curl, #CURLOPT_WRITEDATA, @ftpfile)
 
  curl_easy_setopt(curl, #CURLOPT_USE_SSL, #CURLUSESSL_ALL)
 
  res = curl_easy_perform(curl)
  If res = #CURLE_OK
    Debug "Ok"
  Else
    Debug "Error: " + curl_easy_strerror(res)
  EndIf
 
  If IsFile(ftpfile\file)
    CloseFile(ftpfile\file)
  EndIf
 
  curl_easy_cleanup(curl)
 
EndIf

curl_global_cleanup()

Unfortunately I can not test it :mrgreen:
I have no FTPS server which I can access at the moment.
But it should work. If not: report it.


Last edited by infratec on Wed Nov 25, 2020 5:59 pm, edited 3 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: FTPS (windows needs additional files)
PostPosted: Sun Nov 22, 2020 8:33 pm 
Offline
Addict
Addict

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3965
Location: Berlin, Germany
Quote:
Code:
IncludeFile "libcurl.pbi"

And where can I get "libcurl.pbi"? :-)

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: FTPS (windows needs additional files)
PostPosted: Sun Nov 22, 2020 9:25 pm 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5076
Location: Germany
Ups..

I thought that everyone which has something todo with internet things has it already.

Here a link to a topic with a downloadlink:

viewtopic.php?p=558969#p558969


Top
 Profile  
Reply with quote  
 Post subject: Re: FTPS (windows needs additional files)
PostPosted: Tue Nov 24, 2020 3:41 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4806
Location: Lyon - France
Thanks a lot for this very useful code for me waiting a native FTPS PB function 8)

For connecting to my 1&1 IONOS FTPS space, i have the host
Code:
accessXXXXXXX.webspace-data.io
I have the username
Code:
uXXXXXXXXX
And i have the password
Code:
Password
So i enter in curl_easy_setopt_str()
Code:
curl_easy_setopt_str(curl, #CURLOPT_URL, "ftps://uXXXXXXXXX:Password@accessXXXXXXX.webspace-data.io/Domain.fr/My/Path/file.txt")
And i have this answer :|
PB wrote:
Error: Unsupported protocol

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: FTPS (windows needs additional files)
PostPosted: Tue Nov 24, 2020 4:12 pm 
Offline
New User
New User

Joined: Fri Sep 06, 2019 8:25 pm
Posts: 2
Kwai chang caine wrote:
Thanks a lot for this very useful code for me waiting a native FTPS PB function 8)

For connecting to my 1&1 IONOS FTPS space, i have the host
Code:
accessXXXXXXX.webspace-data.io
I have the username
Code:
uXXXXXXXXX
And i have the password
Code:
Password
So i enter in curl_easy_setopt_str()
Code:
curl_easy_setopt_str(curl, #CURLOPT_URL, "ftps://uXXXXXXXXX:Password@accessXXXXXXX.webspace-data.io/Domain.fr/My/Path/file.txt")
And i have this answer :|
PB wrote:
Error: Unsupported protocol



Another way for FTPS is RSBasics FTP.EX :
viewtopic.php?f=27&t=70380&hilit=ftps


Top
 Profile  
Reply with quote  
 Post subject: Re: FTPS (windows needs additional files)
PostPosted: Tue Nov 24, 2020 4:22 pm 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5076
Location: Germany
@KCC

have you downloaded the needed dlls?
have you uncomment #LibCurl_DLL$ = "libcurl.dll" in the libcurl.pbi file?

Else only the internal libcurl lib is used which can only handle http and smtp.


Top
 Profile  
Reply with quote  
 Post subject: Re: FTPS (windows needs additional files)
PostPosted: Tue Nov 24, 2020 4:35 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4806
Location: Lyon - France
PeWa wrote:
Another way for FTPS is RSBasics FTP.EX :

Thanks PeWa for your link :wink:
It's right RsBasic made a great works with his library 8)
But I do not like too much use owner librarys :oops:
Sometime she is not updating and if my software use it, it can't be updated too, because source are not availlable :|
It's not the first time that it happens ...
I just use big library, when i'm forced, because numerous programmers are behind, and if one stoppe, the others continue :)
But for the moment, it's not often i must use external or owner library, PB are so strong :shock:
It's the first time i can't do something of banal (Put a file on my server provider IONOS :shock: ) with PB 8)

MasterNet wrote:
have you uncomment #LibCurl_DLL$ = "libcurl.dll" in the libcurl.pbi file?
Shit...i have forgetting :oops:

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: FTPS (windows needs additional files)
PostPosted: Tue Nov 24, 2020 5:35 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4806
Location: Lyon - France
I go in libcurl.pbi and there are not
Code:
#LibCurl_DLL$ = "libcurl.dll"
worst there are not :shock:
Code:
#LibCurl_DLL$
:|

The only one place where there are #LibCurl_DLL$ in "libcurl.pbi", it's here :wink:
Code:
 LibCurl = OpenLibrary(#PB_Any, GetPathPart(ProgramFilename()) + #LibCurl_DLL$)

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: FTPS (windows needs additional files)
PostPosted: Tue Nov 24, 2020 8:39 pm 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5076
Location: Germany
Sorry, but I have many variations off libcurl.pbi

I modified the listing above.

To be more 'free' I decided to set the constant outside of libcurl.pbi.

Download my libcurl zip file (link added above) and use the modified listing.
It should work.


Top
 Profile  
Reply with quote  
 Post subject: Re: FTPS (windows needs additional files)
PostPosted: Tue Nov 24, 2020 8:43 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4806
Location: Lyon - France
Thanks a lot INFRATEC i try and say to you :wink: 8)

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: FTPS (windows needs additional files)
PostPosted: Wed Nov 25, 2020 2:47 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4806
Location: Lyon - France
I have surely do a bullshit somewhere, this time your code say "curl_global_init()" is not a function :|
http://reec.fr/provisoire/FTPS.zip

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: FTPS (windows needs additional files)
PostPosted: Wed Nov 25, 2020 6:00 pm 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5076
Location: Germany
I extended libcurl.pbi

https://www.von-der-salierburg.de/downl ... urldll.zip


Top
 Profile  
Reply with quote  
 Post subject: Re: FTPS (windows needs additional files)
PostPosted: Wed Nov 25, 2020 7:05 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4806
Location: Lyon - France
Thanks a lot INFRATEC 8)
This time i have
Quote:
Error: Timeout was reached
I think it's surely a wrong call of my FTPS server :oops:

If for connecting to my 1&1 IONOS FTPS space, i have the host
Quote:
accessXXXXXXX.webspace-data.io
If my username is
Quote:
uXXXXXXXXX
And my password
Quote:
Password
And i want put the file in this path
Quote:
/Domain.fr/My/Path/
Can you confirm the good call ?
Code:
curl_easy_setopt_str(curl, #CURLOPT_URL, "ftps://uXXXXXXXXX:Password@accessXXXXXXX.webspace-data.io/Domain.fr/My/Path/file.txt")

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: FTPS (windows needs additional files)
PostPosted: Wed Nov 25, 2020 8:14 pm 
Offline
Always Here
Always Here

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 5076
Location: Germany
My example is for download a file, not for upload.

Have you written a upload version?


Top
 Profile  
Reply with quote  
 Post subject: Re: FTPS (windows needs additional files)
PostPosted: Wed Nov 25, 2020 8:35 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4806
Location: Lyon - France
Aaaah !!! excuse me i have not understand that :oops:

In fact i need mainly a upload files
In my project i use only TXT files, so for "upload" txt file i make just a GET request
And for upload screenshot, i use your splendid code PHP 8)
What I miss, it's a FTPS for upload the PHP itself on the server :wink: create folder, put file etc .... for configuring automaticaly the SERVER and can run after my remote program :D

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye