単一のファイル(テキストベース)を完全に処理するハンドラーがあります。.zipファイルを受信できますが、「破損」エラーのためにアクセスできません。これは、バイト配列ではなくテキストストリームとして読み取るためであることがわかっていますが、理解できません。(私の試みは以下です)
編集:破損エラーなしでハンドラーに.zipを受け入れさせる必要があります。破損エラーを乗り越えましたが、以下のコードは破損の問題なしにファイルを処理しますが、ファイルが含まれていない状態で解凍します。
Sub ProcessRequest(ByVal context as HttpContent) Implements IHTTPHandler.ProcessRequest
Try
If Context.Request.HttpMethod() = "POST" Then
context.Response.ContentType = "application/octet-stream"
context.Response.StatusCode = 204
Dim reader as New System.IO.BinaryReader(context.Request.InputStream)
Dim contents as Byte
Dim int as Integer = reader.Basestream.Length
''Problem has got to be here, This loop structure can't be right..
Do While int > 0
contents = reader.readByte()
System.IO.File.WriteAllText("thisismyoutputdirectory"), filename), contents)
Loop
else
''Handle non post cases
end if
Catch ex as Exception
''Error Handling is here
End Try
End Sub
代わりにStreamreader
を使用してBinaryReader
います。WriteAllBytes
内容をバイト配列として保存し、メソッドを使用してすべてを書き出そうとしました。
私は実験を続けますが、どんなガイダンスも素晴らしいでしょう!