PB.Ex FTP (Windows)
Re: PB.Ex FTP (Windows)
RSBasic, already a thanks for this.
I will need it probably one of these as you noticed.
Still have a lot to figure out.
I will need it probably one of these as you noticed.
Still have a lot to figure out.
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
- the.weavster
- Addict
- Posts: 1537
- Joined: Thu Jul 03, 2003 6:53 pm
- Location: England
Re: PB.Ex FTP (Windows)
Thank you, RSBasicRSBasic wrote:PureBasic can neither SFTP (SSH File Transfer Protocol) nor FTPS (FTP over SSL/TLS). With this library this is possible.
This library was a big help for me today
Re: PB.Ex FTP (Windows)
Better late than never, but thanks heaps RSBasic, this is exactly what I need right now.
Now all I have to do is download it through our (work) ISP who flags your site as having a malicious reputation....grrrrrrrrrrrrrrrr!!!!!!!!!!!!!!!
Regards,
Amundo
Now all I have to do is download it through our (work) ISP who flags your site as having a malicious reputation....grrrrrrrrrrrrrrrr!!!!!!!!!!!!!!!
Regards,
Amundo
Win8.1, PB5.x, okayish CPU, onboard video card, fuzzy monitor (or is that my eyesight?)
"When the facts change, I change my mind" - John Maynard Keynes
"When the facts change, I change my mind" - John Maynard Keynes
Re: PB.Ex FTP (Windows)
Hi,
I'm trying to use this library in something, but am running into a problem where the first connection to a server works, but later attempts to reconnect to that server fail, and this failure continues until logoff (i.e. quitting and restarting the program doesn't help)
Specifically, I have a process that will periodically have data to upload via FTPS. For what this process needs to do, it doesn't need to look at what's in the FTP server folder, so is not using ExamineFTPDirectoryEx(), but going straight to uploading its files. This is partly because it doesn't need to know what's there, but also because the folder its uploading to may have a high filecount, so enumerating the contents would be slow.
Another process is looking at the upload location (not by FTP) to process the files that appear there. To avoid file locking issues between the upload and processing systems, I upload as a temporary file name and then rename once the upload completes. As a precaution, I attempt to delete any existing file of the intended final or temporary name before uploading. (This is probably not relevant to the problem, but more of an explanation for why the code below is doing what it does.)
So, the code goes something like this:
This all works for the first upload attempt, the file(s) are uploaded correctly and all is well. CloseFTPEx() returns success.
Subsequent attempts result in OpenFTPEx() returning 0 and setting errorout$ to "Error: Timed out trying to read data from the socket stream!". (I.e. this is reported by the "Failed to connect" line at the end.)
All subsequent attempts to connect fail with this error. Closing the PB application and restarting it doesn't fix it (!) (meaning whatever is stuck is not a PB handle but something more fundamental).
Logging off and back on again clears it (but again, for only one upload). Rebooting also fixes it for one upload.
This looks like something from the first upload is not being closed properly, but I don't see anything I'm missing there. I have a CloseFTPEx() that corresponds with the OpenFTPEx(), am not using IsAsynchron anywhere, and there are no directories I need to finish.
Underlying OS is Win10 1809 (build 17763) 64bit. FTP server is XLightFTPd on Windows. Files being transferred are relatively small (few KB, typically), and are UTF8 text.
Googling the error message leads to pages about the FluentFTP library, such as these:
https://github.com/robinrodricks/FluentFTP/issues/122
https://github.com/robinrodricks/FluentFTP/issues/124
But the suggestions there don't seem to offer anything I can try from within PB.
Any ideas?
I'm trying to use this library in something, but am running into a problem where the first connection to a server works, but later attempts to reconnect to that server fail, and this failure continues until logoff (i.e. quitting and restarting the program doesn't help)
Specifically, I have a process that will periodically have data to upload via FTPS. For what this process needs to do, it doesn't need to look at what's in the FTP server folder, so is not using ExamineFTPDirectoryEx(), but going straight to uploading its files. This is partly because it doesn't need to know what's there, but also because the folder its uploading to may have a high filecount, so enumerating the contents would be slow.
Another process is looking at the upload location (not by FTP) to process the files that appear there. To avoid file locking issues between the upload and processing systems, I upload as a temporary file name and then rename once the upload completes. As a precaution, I attempt to delete any existing file of the intended final or temporary name before uploading. (This is probably not relevant to the problem, but more of an explanation for why the code below is doing what it does.)
So, the code goes something like this:
Code: Select all
errorout$=Space(128)
ftphnd=OpenFTPEx(#PB_Any, #PBEx_FTP_Protocol_FTPS_Explicit, server$, 21, user$, pass$, #PB_UTF8, @errorout$)
If ftphnd
Debug "Got ftp handle: "+Str(ftphnd)
; Delete any existing real or temp file. Probably none, so ignore errors.
DeleteFTPFileEx(ftphnd, desttmp$, @errorout$)
DeleteFTPFileEx(ftphnd, destfinal$, @errorout$)
; Upload to temp file then rename.
errorout$=Space(128)
If SendFTPFileEx(ftphnd, src$, desttmp$, #False, @errorout$)
Debug "ftp upload successful, renaming destination."
errorout$=Space(128)
If RenameFTPFileEx(ftphnd, desttmp$, destfinal$, @errorout$)
Debug "ftp rename successful, deleting local file"
DeleteFile(src$)
Else
Debug "Unable to rename file"+desttmp$+" : "+Trim(errorout$)
EndIf
Else
Debug "Unable to upload file: "+src$+" : "+Trim(errorout$)
EndIf
Debug "Closing FTP connection"
errorout$=Space(128)
result=CloseFTPEx(ftphnd, @errorout$)
Debug "Result: "+Str(result)+" : "+Trim(errorout$)
ftphnd=0
Else
Debug "Failed to connect to FTP : "+Trim(errorout$)
EndIf
Subsequent attempts result in OpenFTPEx() returning 0 and setting errorout$ to "Error: Timed out trying to read data from the socket stream!". (I.e. this is reported by the "Failed to connect" line at the end.)
All subsequent attempts to connect fail with this error. Closing the PB application and restarting it doesn't fix it (!) (meaning whatever is stuck is not a PB handle but something more fundamental).
Logging off and back on again clears it (but again, for only one upload). Rebooting also fixes it for one upload.
This looks like something from the first upload is not being closed properly, but I don't see anything I'm missing there. I have a CloseFTPEx() that corresponds with the OpenFTPEx(), am not using IsAsynchron anywhere, and there are no directories I need to finish.
Underlying OS is Win10 1809 (build 17763) 64bit. FTP server is XLightFTPd on Windows. Files being transferred are relatively small (few KB, typically), and are UTF8 text.
Googling the error message leads to pages about the FluentFTP library, such as these:
https://github.com/robinrodricks/FluentFTP/issues/122
https://github.com/robinrodricks/FluentFTP/issues/124
But the suggestions there don't seem to offer anything I can try from within PB.
Any ideas?
Re: PB.Ex FTP (Windows)
@mikejs:
I make a project with this dll and I use SFTP Connection. I find out that #PB_Any sometimes work and sometimes not.
So try out if your connections will work if you are using a fixed ID for that....
e.g. OpenFTPEx(1, Server......
I make a project with this dll and I use SFTP Connection. I find out that #PB_Any sometimes work and sometimes not.
So try out if your connections will work if you are using a fixed ID for that....
e.g. OpenFTPEx(1, Server......
Re: PB.Ex FTP (Windows)
Hi
Thanks for the great DLL files but I have a bit of an issue. I'm writing a downloader for Amiga WHDLoad files and if I try to download the following file , ReceiveFTPFileEx give me nothing.
100MostRememberedGamesOnThe64_v1.01_PerhåkanSundell&RonBirk.lha
I'm pretty sure it's the 'å' that is doing it. Possibly it's a Ascii -> Unicode problem. I've set up OpenFTPEx as #PB_Ascii as the Turran FTP server requires it, though UTF-8 will connect and give the same error. Unicode just gives me an error.
These are the settings I'm using...
Protocol: #PBEx_FTP_Protocol_FTP (Doesn't work with anything else!)
Server: grandis.nu
Port: 21
User: ftp
Pass: amiga
Connection: Passive
Folder: /Retroplay WHDLoad Packs/Commodore_Amiga_-_WHDLoad_-_Demos/0
I have tried the native Purebasic library but some of the guys who tried to download files got no response from the FTP. These DLL's work the best.
Thanks for the great DLL files but I have a bit of an issue. I'm writing a downloader for Amiga WHDLoad files and if I try to download the following file , ReceiveFTPFileEx give me nothing.
100MostRememberedGamesOnThe64_v1.01_PerhåkanSundell&RonBirk.lha
I'm pretty sure it's the 'å' that is doing it. Possibly it's a Ascii -> Unicode problem. I've set up OpenFTPEx as #PB_Ascii as the Turran FTP server requires it, though UTF-8 will connect and give the same error. Unicode just gives me an error.
These are the settings I'm using...
Protocol: #PBEx_FTP_Protocol_FTP (Doesn't work with anything else!)
Server: grandis.nu
Port: 21
User: ftp
Pass: amiga
Connection: Passive
Folder: /Retroplay WHDLoad Packs/Commodore_Amiga_-_WHDLoad_-_Demos/0
I have tried the native Purebasic library but some of the guys who tried to download files got no response from the FTP. These DLL's work the best.
Re: PB.Ex FTP (Windows)
this DLL works fine as FTP but doesn't work as FTPS when I try to connect to my FileZilla server
Re: PB.Ex FTP (Windows)
Thanks, but could you update your link of your zip-file, because none of the links is working? I'm not a professional, so I need examples
Re: PB.Ex FTP (Windows)
Ups ...
I decided to make an own topic about my libcurl.pbi where I put one link at a central place:
viewtopic.php?p=591235
I decided to make an own topic about my libcurl.pbi where I put one link at a central place:
viewtopic.php?p=591235
- RSBasic
- Moderator
- Posts: 1218
- Joined: Thu Dec 31, 2009 11:05 pm
- Location: Gernsbach (Germany)
- Contact:
Re: PB.Ex FTP (Windows)
Hellomrv2k wrote: ↑Sat Dec 25, 2021 3:40 pm Hi
Thanks for the great DLL files but I have a bit of an issue. I'm writing a downloader for Amiga WHDLoad files and if I try to download the following file , ReceiveFTPFileEx give me nothing.
100MostRememberedGamesOnThe64_v1.01_PerhåkanSundell&RonBirk.lha
I'm pretty sure it's the 'å' that is doing it. Possibly it's a Ascii -> Unicode problem. I've set up OpenFTPEx as #PB_Ascii as the Turran FTP server requires it, though UTF-8 will connect and give the same error. Unicode just gives me an error.
I tried to download a file with this filename from my FTP server. It works without error.
Code: Select all
Debug ReceiveFTPFileEx(1, "100MostRememberedGamesOnThe64_v1.01_PerhåkanSundell&RonBirk.lha", "D:\100MostRememberedGamesOnThe64_v1.01_PerhåkanSundell&RonBirk.lha", 0, @ErrorOutput$)
Debug ErrorOutput$
I can't confirm.
- RSBasic
- Moderator
- Posts: 1218
- Joined: Thu Dec 31, 2009 11:05 pm
- Location: Gernsbach (Germany)
- Contact:
Re: PB.Ex FTP (Windows)
Hellomikejs wrote: ↑Mon Jun 08, 2020 3:10 pm I'm trying to use this library in something, but am running into a problem where the first connection to a server works, but later attempts to reconnect to that server fail, and this failure continues until logoff (i.e. quitting and restarting the program doesn't help)
Specifically, I have a process that will periodically have data to upload via FTPS. For what this process needs to do, it doesn't need to look at what's in the FTP server folder, so is not using ExamineFTPDirectoryEx(), but going straight to uploading its files. This is partly because it doesn't need to know what's there, but also because the folder its uploading to may have a high filecount, so enumerating the contents would be slow.
Another process is looking at the upload location (not by FTP) to process the files that appear there. To avoid file locking issues between the upload and processing systems, I upload as a temporary file name and then rename once the upload completes. As a precaution, I attempt to delete any existing file of the intended final or temporary name before uploading. (This is probably not relevant to the problem, but more of an explanation for why the code below is doing what it does.)
This all works for the first upload attempt, the file(s) are uploaded correctly and all is well. CloseFTPEx() returns success.
Subsequent attempts result in OpenFTPEx() returning 0 and setting errorout$ to "Error: Timed out trying to read data from the socket stream!". (I.e. this is reported by the "Failed to connect" line at the end.)
All subsequent attempts to connect fail with this error. Closing the PB application and restarting it doesn't fix it (!) (meaning whatever is stuck is not a PB handle but something more fundamental).
Logging off and back on again clears it (but again, for only one upload). Rebooting also fixes it for one upload.
This looks like something from the first upload is not being closed properly, but I don't see anything I'm missing there. I have a CloseFTPEx() that corresponds with the OpenFTPEx(), am not using IsAsynchron anywhere, and there are no directories I need to finish.
I can't confirm.
I tested with FTP and with SFTP.
Here it works:
I tested several times. He can delete, upload and rename the file.[20:44:11] Got ftp handle: 0
[20:44:11] ftp upload successful, renaming destination.
[20:44:11] ftp rename successful, deleting local file
[20:44:11] Closing FTP connection
[20:44:11] Result: 1 :
I used the following code (based on your code):
Code: Select all
[...]
Define ErrorOutput$ = Space(128)
Define ftphnd
Define desttmp$ = "NtlmTest.temp"
Define src$ = "D:\NtlmTest.cs"
Define destfinal$ = "NtlmTest.cs"
Define result
ftphnd = OpenFTPEx(#PB_Any, #PBEx_FTP_Protocol_FTP, "...........", 21, ".............", ".................", #PB_UTF8, @ErrorOutput$)
If ftphnd > -1
Debug "Got ftp handle: "+Str(ftphnd)
; Delete any existing real or temp file. Probably none, so ignore errors.
DeleteFTPFileEx(ftphnd, desttmp$, @ErrorOutput$)
DeleteFTPFileEx(ftphnd, destfinal$, @ErrorOutput$)
; Upload to temp file then rename.
ErrorOutput$=Space(128)
If SendFTPFileEx(ftphnd, src$, desttmp$, #False, @ErrorOutput$)
Debug "ftp upload successful, renaming destination."
ErrorOutput$=Space(128)
If RenameFTPFileEx(ftphnd, desttmp$, destfinal$, @ErrorOutput$)
Debug "ftp rename successful, deleting local file"
;DeleteFile(src$)
Else
Debug "Unable to rename file"+desttmp$+" : "+Trim(ErrorOutput$)
EndIf
Else
Debug "Unable to upload file: "+src$+" : "+Trim(ErrorOutput$)
EndIf
Debug "Closing FTP connection"
ErrorOutput$=Space(128)
result=CloseFTPEx(ftphnd, @ErrorOutput$)
Debug "Result: "+Str(result)+" : "+Trim(ErrorOutput$)
ftphnd=0
CloseFTPEx(ftphnd, @ErrorOutput$)
Else
Debug ErrorOutput$
EndIf
CloseLibrary(PBEx_FTP)
Code: Select all
public static int CloseFTPEx(int ID, System.IntPtr ErrorOutput) {
[...]
PBIDObject[ID].FTPConnection.Disconnect();
PBIDObject[ID].FTPConnection.Dispose();
PBIDObject[ID].FTPConnection = null;
PBIDObject[ID].Files.Clear();
[...]
}
- RSBasic
- Moderator
- Posts: 1218
- Joined: Thu Dec 31, 2009 11:05 pm
- Location: Gernsbach (Germany)
- Contact:
Re: PB.Ex FTP (Windows)
PB.Ex FTP 1.0.6.0 has been released.
Changelog:
Changelog:
- Updated: .NET Framework 4 > .NET Framework 4.7.2
- Improved: FTPDirectoryEntrySizeEx(): x86 version: Size of files larger than 4 GB can be read.
- Added: AbortFTPFileEx()
DoneCalamityJames wrote: ↑Fri Oct 08, 2021 4:06 pm The function FTPDirectoryEntrySizeEx seems to return an integer which is not really enough for some recent video files (in 32bit). By a bit of peeking and poking with a Purebasic quad it is possible to treat the returned integer as unsigned which means the maximum files size returned correctly is 4294967295. There are still video files bigger than this, though.