FTP scriptyness |
FTP scriptyness |
Oct 7 2008, 03:33 PM
Post
#1
|
|
Security and Projects Group: Clan Dogsbody Posts: 4,687 Thank(s): 1098 Points: 2,440 Joined: 31-August 07 From: A Magical Place, with toys in the million, all under one roof Member No.: 1 |
Firstly would it not be easier to script it so that a bunch of files are packaged - zipped or preferably tarred and then upload the one file then untar it on the remote server??
Something like the following run on "Remote server" => "computer where files are kept" (Dirty FTP connections*) On server, create a local ghey.zip and fills it from the FTP request. WebRequest.RegisterPrefix("ftp://", FtpWebRequest.Creator); WebRequest request = WebRequest.Create("ftp://ftp.magik5likesmen.com/ghey.tar.gz"); WebResponse response = request.GetResponse(); Stream stream = response.GetResponseStream(); Stream local = File.Create("ghey.tar.gz"); byte[] buffer = new byte[1024]; int n; do { n = stream.Read(buffer, 0, buffer.Length); local.Write(buffer, 0, n); } while (n > 0); stream.Close(); local.Close(); **then something like.. (I can't remember the syntax )*** gz.UnTarGz("ghey.tar.gz", untarRoot, bNoAbsolute); Obviously this can be rejigged if you want to run as a script on the "computer where files are kept" > "Remote Server" type direction *I do it this way so that a remote secure server never accepts inbound FTP connections, it should always initiate outbound connections by script. This means that the script can run with limited permissions e.g. run under a user to reach the outside world and place files in a given limited directory with no permissions outside of that directory. A separate script with permissions to this directory but no permissions to the outside world can then be run to unpack and palce the files where they belong; this is purely limiting security. -------------------- |
|
|
Oct 8 2008, 08:28 AM
Post
#2
|
|
Paddle Master Group: Clan Members Posts: 2,085 Thank(s): 30 Points: 317 Joined: 3-December 07 Member No.: 50 |
nice idea on the security thing as well, but the only people using this will be staff uploading to our server so security shouldn't really be an issue.
i had a little dig around google as it seems c# only supports zipping one file at a time, where as i need to zip (sometimes multiple folders) containing multiple files into one zip. the ftp app works just fine as is, albeit a few annoying 550's every so often, and ive got the rest of the php stuff to be getting on with so if theres a quick simple solution for this then great, if not its not really an issue =] oh one more thing - on the first connection it makes, the app seems to hang until connection is made, short of going down the threading route, do you no of a quick fix for this? cheers -------------------- |
|
|
Lo-Fi Version | Time is now: 24th November 2024 - 10:36 AM |