|
ftp_download
#450873
04/24/15 06:24
04/24/15 06:24
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
There isn't much documentation in the manual about this. I tried to use the example with my own credentials, and it doesnt work, although Im certain it should. Im entering the same info id use to log into filezilla. Can you please help me in the right direction?
ftp_download("ftp//:www.host.com/model.mdl", "models/model.mdl", "USER", "PASSWORD");
while (!ftp_status()) //as long as the download is running
{ //get informations about the download:
fsize = ftp_size();
fsent = ftp_sent();
wait(1);
}
if (ftp_status() == 1)
printf("Download successful!");
else
printf("Error during download!");
Thank you for your time.
Last edited by DLively; 04/24/15 08:20.
|
|
|
Re: ftp_download
[Re: jcl]
#450887
04/24/15 12:56
04/24/15 12:56
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
Thanks for your reply Jcl, yeah.. [face palm] I noticed the Url was wrong after I posted my question.. I thought I updated that. I tried using an absolute path, and with no luck im still getting "error during download" ftp_size becomes -1, and ftp_sent stays at 0. Here is the updated code:
#define ADDRESS "ftp://www.host.com/model.mdl"
#define _PATH "E:/projectfolder/models/model.mdl"
#define USER "filezilla_user"
#define PASS "filezilla_pass"
void update_game(){
ftp_debug(1);
ftp_download(ADDRESS, _PATH, USER, PASS);
while (!ftp_status()) //as long as the download is running
{ //get informations about the download:
fsize = ftp_size();
fsent = ftp_sent();
DEBUG_VAR(fsize, 100);
DEBUG_VAR(fsent, 120);
wait(1);
}
if (ftp_status() == 1)
printf("Download successful!");
else
printf("Error during download!");
}
function main(){
update_game();
wait_for(update_game);
...
}
Last edited by DLively; 04/24/15 13:13.
|
|
|
Re: ftp_download
[Re: jcl]
#450914
04/24/15 17:07
04/24/15 17:07
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
Unfortunately, I purchased my Professional Licence Used -- Furthermore, I purchased it used over a year ago. Both ftp logs are the same -> Everything works fine and its connecting to the server, however it appears that it is having trouble downloading the file I am requesting, because it does register that I am looking for the entered file. But apparently it can't find that file..
> TYPE I
< 200 TYPE is now 8-bit binary
> SIZE hero.mdl
< 550 Can't check for file existence
> RETR hero.mdl
< 550 Can't open hero.mdl: No such file or directory
* RETR response: 550
* Remembering we are in dir ""
* Connection #0 to host www.devonlively.com left intact
* Remote file not found
> QUIT
< 221-Goodbye. You uploaded 0 and downloaded 0 kbytes.
< 221 Logout.
* Closing connection #0
Hopefully Someone can fill in the blanks from here for me..
Last edited by DLively; 04/24/15 17:12.
|
|
|
Re: ftp_download
[Re: DLively]
#450928
04/24/15 23:09
04/24/15 23:09
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
Serious User
|
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
Stop using 3DGS stuff and use WinAPI combined with Winsock2. Takes 10 mins to implement it to a new project and add it as plugin to your game. Google is full of results on how to download a file with it from a remote server
Last edited by Ch40zzC0d3r; 04/24/15 23:09.
|
|
|
Re: ftp_download
[Re: DLively]
#450937
04/25/15 05:42
04/25/15 05:42
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
////////////////////////////////////////////////////////////////////////////////
// lite-c header for http / ftp functions
// (c) 2009 Peter Soxberger / oP group Germany
////////////////////////////////////////////////////////////////////////////////
#ifndef ACKNET_H
#define ACKNET_H
#define PRAGMA_BIND "acknet.dll";
var http_proxy(char* proxy,var port);
var http_sendpost(char* url, char* data);
var http_status(var httpid);
var http_result(var httpid, STRING* result);
var http_free(var httpid);
var ftp_download(char* url, char* path, char* username, char* password);
var ftp_upload(char* url, char* path, char* username, char* password);
var ftp_getdate(char* url, char* username, char* password);
void ftp_stop();
long ftp_size();
long ftp_sent();
long ftp_timestamp();
var ftp_status();
var ftp_debug(var mode);
#endif
How is this being taken from the dll? // - using this as an example, I don't understand.
public class HttpRemoteDownload : RemoteDownload
{
public HttpRemoteDownload(string urlString, string descFilePath)
: base(urlString, descFilePath)
{
}
public override bool DownloadFile()
{
string fileName = System.IO.Path.GetFileName(this.UrlString);
string descFilePathAndName =
System.IO.Path.Combine(this.DescFilePath, fileName);
try
{
WebRequest myre = WebRequest.Create(this.UrlString);
}
catch
{
return false;
}
try
{
byte[] fileData;
using (WebClient client = new WebClient())
{
fileData = client.DownloadData(this.UrlString);
}
using (FileStream fs =
new FileStream(descFilePathAndName, FileMode.OpenOrCreate))
{
fs.Write(fileData, 0, fileData.Length);
}
return true;
}
catch (Exception ex)
{
throw new Exception("download field", ex.InnerException);
}
}
}
public class FtpRemoteDownload : RemoteDownload
{
public FtpRemoteDownload(string urlString, string descFilePath)
: base(urlString, descFilePath)
{
}
public override bool DownloadFile()
{
FtpWebRequest reqFTP;
string fileName = System.IO.Path.GetFileName(this.UrlString);
string descFilePathAndName =
System.IO.Path.Combine(this.DescFilePath, fileName);
try
{
reqFTP = (FtpWebRequest)FtpWebRequest.Create(this.UrlString);
reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
reqFTP.UseBinary = true;
using (FileStream outputStream = new FileStream(descFilePathAndName, FileMode.OpenOrCreate))
using (FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse())
using (Stream ftpStream = response.GetResponseStream())
{
int bufferSize = 2048;
int readCount;
byte[] buffer = new byte[bufferSize];
readCount = ftpStream.Read(buffer, 0, bufferSize);
while (readCount > 0)
{
outputStream.Write(buffer, 0, readCount);
readCount = ftpStream.Read(buffer, 0, bufferSize);
}
}
return true;
}
catch (Exception ex)
{
throw new Exception("upload failed", ex.InnerException);
}
}
}
|
|
|
|