Sub Handle(Req As ServletRequest, Resp As ServletResponse)
Request = Req
Response = Resp
If Request.Method <> "POST" Then
HttpUtility.ReturnErrorResponse("Only POST Request is allowed", 405, Response)
Return
End If
ProcessRequest
End Sub
Private Sub ProcessRequest
Dim In As InputStream = Request.InputStream
Dim uploadDirectory As String = FileUtility.GetUploadDirectory(Main.Config.Get("DefaultUploadDirectory"))
Dim mulitpartFormData As Map = Request.GetMultipartData(uploadDirectory, 10000000)
Dim filePart As Part = mulitpartFormData.Get("file")
Log($"filePart.SubmittedFilename => ${filePart.SubmittedFilename}"$)
Dim newFileName As String = FileUtility.GenerateNewFileName(filePart.SubmittedFilename)
Log($"newFileName => ${newFileName}"$)
'Log($"filePart.TempFile => ${filePart.TempFile}"$)
Dim out As OutputStream = File.OpenOutput(uploadDirectory, newFileName, False)
File.Copy2(In, out)
out.Close
End Sub