Dev2.Data.PathOperations.Dev2FTPProvider.Put C# (CSharp) Method

Put() public method

public Put ( Stream src, IActivityIOPath dst, Dev2CRUDOperationTO args, string whereToPut, List filesToCleanup ) : int
src Stream
dst IActivityIOPath
args Dev2.PathOperations.Dev2CRUDOperationTO
whereToPut string
filesToCleanup List
return int
        public int Put(Stream src, IActivityIOPath dst, Dev2CRUDOperationTO args, string whereToPut, List<string> filesToCleanup)
        {
            var result = -1;

            bool ok;

            if(args.Overwrite)
            {
                ok = true;
            }
            else
            {
                // try and fetch the file, if not found ok because we not in Overwrite mode
                try
                {
                    using(Get(dst, filesToCleanup))
                    {
                        ok = false;
                    }
                }
                catch(Exception ex)
                {
                    Dev2Logger.Log.Error(this, ex);
                    ok = true;
                }
            }

            if(ok)
            {
                try
                {
                    result = IsStandardFtp(dst) ? WriteToFtp(src, dst) : WriteToSftp(src, dst);
                }
                catch(Exception ex)
                {
                    Dev2Logger.Log.Debug("Exception in Put command");
                    Dev2Logger.Log.Debug(ex.Message);
                    Dev2Logger.Log.Debug(ex.StackTrace);

                    Dev2Logger.Log.Error(this, ex);
                    throw;
                }
            }
            return result;
        }