8 Aralık 2009, Salı
Ftp Upload " Active Directory dosyaları
Powershell anonim bir FTP sunucusuna FTP ile dosyaları aktarmak için kullanmak istiyorum. Herhangi bir ekstra paketleri kullanmazdım. Nasıl?
Komut kilitleniyor ya da çöküyor risk olmalı.
CEVAP
8 Aralık 2009, Salı
İşler kontrolümüz (sunucu güç orta-upload? kaybederse ne) dışında olduğu gibi 100% kurşun asılı değil, senaryoyu kanıt ya da çökmesini, emin değilim - ama bu size başlamak için sağlam bir temel sağlamalıdır:
# create the FtpWebRequest and configure it
$ftp = [System.Net.FtpWebRequest]::Create("ftp://localhost/me.png")
$ftp = [System.Net.FtpWebRequest]$ftp
$ftp.Method = [System.Net.WebRequestMethods Ftp]::UploadFile
$ftp.Credentials = new-object System.Net.NetworkCredential("anonymous","anonymous@localhost")
$ftp.UseBinary = $true
$ftp.UsePassive = $true
# read in the file to upload as a byte array
$content = [System.IO.File]::ReadAllBytes("C:\me.png")
$ftp.ContentLength = $content.Length
# get the request stream, and write the bytes into it
$rs = $ftp.GetRequestStream()
$rs.Write($content, 0, $content.Length)
# be sure to clean up after ourselves
$rs.Close()
$rs.Dispose()
Bunu PaylaÅŸ:
Web görünümü dosya Upload...
Maven olmadan Nexus Upload eserler, ...
nginx upload client_max_body_size soru...
4 çoklu resim raylar veya upload carri...
Amazon S3 istemci tarayıcı doğrudan do...