Reputation: 2246
I have a requirement of uploading several image files to FTP.
The main goal to achieve here is performance, speed.
My approach here is to, zip all files at client end, and ftp upload them and un-archive them back on server.
Is there any better approach??
and what is the best way to zip like 1000 images? Should I use .net inbuild mechanism OR some external library?
Note : I have VS 2012 development environment for this.
Upvotes: 0
Views: 852
Reputation: 8902
Zip it on the client
end and FTP it and unzip them on the server
would be best approach in term of performance and speed. sending 1000+ files to the server will not be a ideal solution.
Better to use open source libraries to zip the files. You may use Ionic Zip. You can easily zip and unzip files using the exposed API.
Code Sample
Zipping Files
using (ZipFile zip = new ZipFile())
{
// add this map file into the "images" directory in the zip archive
zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images");
zip.Save("MyZipFile.zip");
}
Unzipping files
public void ExtractZipFile(string fullZipFileName, string extractPath)
{
using (ZipFile zip = ZipFile.Read(fullZipFileName))
{
//Extract the zip file
zip.ExtractAll(extractPath);
};
}
Upvotes: 1