English 中文(简体)
每2或3个后继有效载荷后卸载
原标题:Ftp uploading failed after every two or three succeeded uploads

在上载时,我收到以下错误信息。 Powerhell使用7za.exe创建了一个齐p文档,并称我的FLTP功能是上载文件。 可能引起这一问题的是什么? Windows ftp。 外部客户更加稳定?

Exception calling "GetRequestStream" with "0" argument(s): "The remote server returned an error: (550) File unavailable (e.g., file not found, no access)."

Update:
It seems the same files always failed in the loop. However, It works if I just run ftpFile file_name_with_full_path. (The file_name_with_full_path is copied from the output of the loop script.

Update 2:
I tried to use webclient ($webclient.UploadFile($uri, $File)) to ftp the files. Same error.

Update 3:
Found this Question. May need to add $ftp.KeepAlive = false. Why?

function ftpFile
{
    Param (
        [Parameter(Mandatory=$true, ValueFromPipeline=$true)]
        [ValidateScript({Test-Path $_})]
        [String] 
        $filePath
        ,
        [Parameter(Mandatory=$false)]
        [String]
        $ftpUrl = "ftp://10.0.1.1/Data/"
        ,
        [Parameter(Mandatory=$false)]
        [String]
        $Login = "username"
        ,    
        [Parameter(Mandatory=$false)]
        [String]
        $password = "password"
    )
    Process {
        try {
            $ftp = [System.Net.FtpWebRequest]::Create("$ftpUrl/$(Split-Path $filePath -Leaf)")
            $ftp = [System.Net.FtpWebRequest]$ftp
            $ftp.Method = [System.Net.WebRequestMethods+Ftp]::UploadFile
            $ftp.Credentials = new-object System.Net.NetworkCredential("$Login","$password")
            $ftp.UseBinary = $true
            $ftp.UsePassive = $true

            # read in the file to upload as a byte array
            $content = gc -en byte $filePath
            $ftp.ContentLength = $content.Length

            # get the request stream, and write the bytes into it
            $rs = $ftp.GetRequestStream()
            $rs.Write($content, 0, $content.Length)
            $rs.Close()
            $rs.Dispose()

            echo "ftpFile: $filePath size: $($content.Length)"
        }
        catch {
            throw "FTP: $_"
        }
    }
}
最佳回答

1. 提出这一问题。 添加<代码>ftp.KeepAlive = 虚假。

问题回答

FTP Error 550是“无障碍”,往往是一个用户名/密码冲突。

If you re using a loop and passing the same username and password each time this function is called AND it s working on some iterations of the loops and not others THEN you need to check the ftp auth/error logs on the server to get a grasp of why you re being denied.

正如“AndyArismendi”所问,它是否总是在同一档案中失败? 如果没有更完整的法典和对你的使用的理解,就很难找到简单的解决办法。





相关问题
What is the simplest way to create my own FTP server?

What is the simplest way to create my own FTP server in C#? Some of the folders will be virtual folders. The authentication should be from a SQL Server database, which includes tables of the ASP.NET ...

FTP In/Out Folder Name Best Practices

What best practices (if any) do you adhere to regarding setting up outgoing and incoming folders for your FTP clients? We typically use "outgoing" and "incoming", but no matter how you phrase the ...

Using TCPClient with RAW FTP to retrieve file

I get the following message back when trying to retrieve a file using TCPClient and RAW FTP: 425 Failed to establish connection. I connect using : using (TcpClient client = new TcpClient("...

Retrieving a List of Files from an FTP server in C#

I m trying to retrieve a list of files from an FTP server, but I m getting some weird non-ASCII responses. Here is the code that I am using: public string[] getFileList(string mask) { if(!...

FTP error on Quit command

I m using a ftp library that causes an error sending the quit command. It seems that the character before QUIT is not recognized. I took a look at the code but didn t find anything. 500 ?QUIT : ...

Passive FTP Timeout while using WinINet

I m trying to ftp a file using passive ftp but I get a timeout (12002) when the put command is called. I m able to use passive ftp with other ftp sites but not this new one. I ve tried this using ...

热门标签