/// <summary>
        ///   Upload a file to the FTP server
        /// </summary>
        /// <param name="localFilePath">Full local path to the file</param>
        /// <param name="remoteFileName">Target filename</param>
        /// <returns>ContentURL</returns>
        protected string UploadFile(string localFilePath, string remoteFileName, out long fileLength)
        {
            string hydranetFtpServerAddress = System.Configuration.ConfigurationManager.AppSettings["HydranetFtpServerAddress"];
            if (String.IsNullOrEmpty(hydranetFtpServerAddress))
                throw new FormatException("Invalid HydranetFtpServerAddress check the application or web config file");
            else
                hydranetFtpServerAddress = hydranetFtpServerAddress.Trim();

            int hydranetFtpServerPort = 0;
            if (!int.TryParse(System.Configuration.ConfigurationManager.AppSettings["HydranetFtpServerPort"], out hydranetFtpServerPort))
                throw new FormatException("Invalid HydranetFtpServerPort check the application or web config file");

            string hydranetFtpUsername = System.Configuration.ConfigurationManager.AppSettings["HydranetFtpUsername"];
            if (String.IsNullOrEmpty(hydranetFtpUsername))
                throw new FormatException("Invalid HydranetFtpUsername check the application or web config file");
            else
                hydranetFtpUsername = hydranetFtpUsername.Trim();

            string hydranetFtpPassword = System.Configuration.ConfigurationManager.AppSettings["HydranetFtpPassword"];
            if (String.IsNullOrEmpty(hydranetFtpPassword))
                throw new FormatException("Invalid HydranetFtpPassword check the application or web config file");
            else
                hydranetFtpPassword = hydranetFtpPassword.Trim();

            string hydranetFtpBaseFilePath = System.Configuration.ConfigurationManager.AppSettings["HydranetFtpBaseFilePath"];
            if (String.IsNullOrEmpty(hydranetFtpBaseFilePath))
                throw new FormatException("Invalid HydranetFtpBaseFilePath check the application or web config file");
            else
                hydranetFtpBaseFilePath = hydranetFtpBaseFilePath.Trim();

            string hydranetFtpHttpBaseUrl = System.Configuration.ConfigurationManager.AppSettings["HydranetFtpHttpBaseUrl"];
            if (String.IsNullOrEmpty(hydranetFtpHttpBaseUrl))
                throw new FormatException("Invalid HydranetFtpHttpBaseUrl check the application or web config file");
            else
                hydranetFtpHttpBaseUrl = hydranetFtpHttpBaseUrl.Trim();

            string hydranetFtpRemoteFilePath = System.Configuration.ConfigurationManager.AppSettings["HydranetFtpRemoteFilePath"];
            if (String.IsNullOrEmpty(hydranetFtpRemoteFilePath))
                throw new FormatException("Invalid HydranetFtpRemoteFilePath check the application or web config file");
            else
                hydranetFtpRemoteFilePath = hydranetFtpRemoteFilePath.Trim();

            FileTransfer fileTransfer = new FileTransfer(hydranetFtpServerAddress, hydranetFtpServerPort, hydranetFtpUsername, hydranetFtpPassword, hydranetFtpBaseFilePath, hydranetFtpHttpBaseUrl);
            fileLength = -1;
            return fileTransfer.Upload(localFilePath, hydranetFtpRemoteFilePath, remoteFileName, out fileLength);
        }
        /// <summary>
        /// Deletes content from the external FTP server
        /// </summary>
        /// <param name="objectPID">ObjectPID</param>
        /// <param name="dsId">DatastreamId of the content to delete</param>
        protected void DeleteExternalContent(string objectPID, string dsId)
        {
            string fileLocation;
            string filename;

            using (OperationContextScope scope = new OperationContextScope(_fedoraManagement.FedoraManagementProxy.InnerChannel))
            {
                uk.ac.hull.repository.hydranet.serviceref.fedoramanagement.Datastream datastream = _fedoraManagement.getDatastream(objectPID, dsId, "", scope);
                fileLocation = datastream.location;
                filename = fileLocation.Substring(fileLocation.LastIndexOf('/') + 1);
            }

            string ftpServerAddress = "rep1.adir.hull.ac.uk";
            int ftpServerPort = 2121;
            string ftpUsername = "******";
            string ftpPassword = "******";
            string ftpBaseFilePath = "test/";
            string httpBaseUrl = "http://rep1.adir.hull.ac.uk";

            FileTransfer fileTransfer = new FileTransfer(ftpServerAddress, ftpServerPort, ftpUsername, ftpPassword, ftpBaseFilePath, httpBaseUrl);

            fileTransfer.Delete("test/Users/", filename);
        }