public string UnZip(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst,
Dev2UnZipOperationTO args)
{
string status;
try
{
status = ValidateUnzipSourceDestinationFileOperation(src, dst, args, () =>
{
ZipFile zip;
var tempFile = "";
if(src.RequiresLocalTmpStorage())
{
var tmpZip = CreateTmpFile();
using(var s = src.Get(src.IOPath, _filesToDelete))
{
File.WriteAllBytes(tmpZip, s.ToByteArray());
}
tempFile = tmpZip;
zip = ZipFile.Read(tempFile);
}
else
{
zip = ZipFile.Read(src.Get(src.IOPath, _filesToDelete));
}
if(dst.RequiresLocalTmpStorage())
{
// unzip locally then Put the contents of the archive to the dst end-point
var tempPath = CreateTmpDirectory();
ExtractFile(args, zip, tempPath);
var endPointPath = ActivityIOFactory.CreatePathFromString(tempPath, "", "","");
var endPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(endPointPath);
Move(endPoint, dst, new Dev2CRUDOperationTO(args.Overwrite));
}
else
{
ExtractFile(args, zip, dst.IOPath.Path);
}
if(src.RequiresLocalTmpStorage())
{
File.Delete(tempFile);
}
return ResultOk;
});
}
finally
{
_filesToDelete.ForEach(RemoveTmpFile);
}
return status;
}