Raised This Month: $101 Target: $400
 25% 

[EXTENSION] System2 - Easy to use HTTP(S)/FTP Request API and useful system natives


Post New Thread Reply   
 
Thread Tools Display Modes
T1MOXA
Member
Join Date: Aug 2016
Old 07-24-2018 , 10:17   Re: [EXTENSION] System2 - Easy to use HTTP(S)/FTP Request API and useful system nativ
Reply With Quote #101

Yes, I know that 7z didn't you.
But unfortunately I did not find a solution to my problem in the network, so I decided to ask you.
Yes, I wrote the plugin for myself.
I'll try a lower compression level.
T1MOXA is offline
694372459
Member
Join Date: Aug 2012
Old 09-08-2018 , 12:20   Re: [EXTENSION] System2 - Easy to use HTTP(S)/FTP Request API and useful system nativ
Reply With Quote #102

Hi, I've tested FTP download feature, after finish the downloaded file is 0kb (empty), can you check it?

P.S the legacy ftp download native works fine

Last edited by 694372459; 09-08-2018 at 12:21.
694372459 is offline
dordnung
Veteran Member
Join Date: Apr 2010
Location: Germany
Old 09-21-2018 , 06:28   Re: [EXTENSION] System2 - Easy to use HTTP(S)/FTP Request API and useful system nativ
Reply With Quote #103

Hey,
can you show me the part of your code, as it works fine for me?
__________________
dordnung is offline
694372459
Member
Join Date: Aug 2012
Old 12-05-2018 , 01:31   Re: [EXTENSION] System2 - Easy to use HTTP(S)/FTP Request API and useful system nativ
Reply With Quote #104

Quote:
Originally Posted by dordnung View Post
Hey,
can you show me the part of your code, as it works fine for me?
Hi, thanks for replying

here's my code:

PHP Code:
#include <sourcemod>
#include <system2>

#define FTP_HOST ""
#define FTP_PORT
#define FTP_USER ""
#define FTP_PWD ""
#define FTP_REQUEST_FILE ""

public OnPluginStart()
{
    
RegServerCmd("test_ftp_download"Command_TestDownload);
}

public 
Action:Command_TestDownload(args)
{
    
System2FTPRequest ftpRequest = new System2FTPRequest(FtpResponseCallbackFTP_REQUEST_FILE);
    
ftpRequest.SetAuthentication(FTP_USERFTP_PWD);
    
ftpRequest.SetPort(FTP_PORT);
    
ftpRequest.SetOutputFile("addons/sourcemod/data/test_ftp_download.txt");
    
ftpRequest.StartRequest(); 
    
delete ftpRequest;
    
    return 
Plugin_Handled;
}

public 
void FtpResponseCallback(bool success, const char[] errorSystem2FTPRequest requestSystem2FTPResponse response) {
    if (
success) {
        
char file[PLATFORM_MAX_PATH];
        
request.GetInputFile(filesizeof(file));

        if (
strlen(file) > 0) {
            
PrintToServer("Download Finished");    
        }
    }

694372459 is offline
Papero
Veteran Member
Join Date: Aug 2016
Location: Rimini, Italy
Old 12-05-2018 , 06:34   Re: [EXTENSION] System2 - Easy to use HTTP(S)/FTP Request API and useful system nativ
Reply With Quote #105

Quote:
Originally Posted by 694372459 View Post
Hi, thanks for replying

here's my code:

PHP Code:
#include <sourcemod>
#include <system2>

#define FTP_HOST ""
#define FTP_PORT
#define FTP_USER ""
#define FTP_PWD ""
#define FTP_REQUEST_FILE ""

public OnPluginStart()
{
    
RegServerCmd("test_ftp_download"Command_TestDownload);
}

public 
Action:Command_TestDownload(args)
{
    
System2FTPRequest ftpRequest = new System2FTPRequest(FtpResponseCallbackFTP_REQUEST_FILE);
    
ftpRequest.SetAuthentication(FTP_USERFTP_PWD);
    
ftpRequest.SetPort(FTP_PORT);
    
ftpRequest.SetOutputFile("addons/sourcemod/data/test_ftp_download.txt");
    
ftpRequest.StartRequest(); 
    
delete ftpRequest;
    
    return 
Plugin_Handled;
}

public 
void FtpResponseCallback(bool success, const char[] errorSystem2FTPRequest requestSystem2FTPResponse response) {
    if (
success) {
        
char file[PLATFORM_MAX_PATH];
        
request.GetInputFile(filesizeof(file));

        if (
strlen(file) > 0) {
            
PrintToServer("Download Finished");    
        }
    }

Shouldn't you close (delete) the FTP request handle (only) in the callback?

Also avoid mixing old and new syntax
__________________

Last edited by Papero; 12-05-2018 at 06:35.
Papero is offline
Send a message via Skype™ to Papero
dordnung
Veteran Member
Join Date: Apr 2010
Location: Germany
Old 12-06-2018 , 12:23   Re: [EXTENSION] System2 - Easy to use HTTP(S)/FTP Request API and useful system nativ
Reply With Quote #106

Quote:
Shouldn't you close (delete) the FTP request handle (only) in the callback?
No it should not be deleted in the callback, as a copy is used there which will be deleted automatically after the callback. It should be deleted after making a request or when not used anymore.

Thanks for reporting it, I found the problem. I've forgot to close the file after downloading, thats why it was empty. This is fixed now.
But the "GetInputFile" part does not make sense. The input file is only set when uploading stuff to a FTP server.

Update to System2 v3.2.1

- Automatically use 32-Bit 7-ZIP when 64-Bit is not executable
- Fix incomplete file when downloading files with FTP
- Added libcurl certificate file for SSL instead of using system's certificate file
- Updated to the latest libcurl version
__________________

Last edited by dordnung; 12-06-2018 at 12:25.
dordnung is offline
T1MOXA
Member
Join Date: Aug 2016
Old 03-31-2019 , 19:10   Re: [EXTENSION] System2 - Easy to use HTTP(S)/FTP Request API and useful system nativ
Reply With Quote #107

For some reason, files are not always archived on the same server, there are no problems with manual compression.
How to understand the cause of the error ?
T1MOXA is offline
NanoC
Senior Member
Join Date: Jan 2016
Location: Argentina
Old 04-06-2019 , 02:58   Re: [EXTENSION] System2 - Easy to use HTTP(S)/FTP Request API and useful system nativ
Reply With Quote #108

Quote:
Originally Posted by T1MOXA View Post
For some reason, files are not always archived on the same server, there are no problems with manual compression.
How to understand the cause of the error ?
something like this?
https://github.com/dordnung/System2/issues/9
__________________
My plugins || Steam || Discord: nano#7638 || Donate via PayPal!
Total donated: $139
NanoC is offline
Send a message via Skype™ to NanoC
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:34.


Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode