#Region Project Attributes
#ApplicationLabel:Uploader
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: False
#End Region
Sub
Process_Globals
Private link As String = "
http://duckdns.org:54021/upload"
Private cc As ContentChooser
End Sub
Sub
Globals
End Sub
Sub
Activity_Create(FirstTime As Boolean)
If FirstTime Then
cc.Initialize("cc")
End If
Activity.LoadLayout("1")
End Sub
Sub
btnSendFile_Click
cc.Show("*/*", "Choose file")
End Sub
Sub
cc_Result (Success As Boolean, Dir As String, FileName As String)
If Success Then
Dim j As HttpJob
Dim out As OutputStream
out.InitializeToBytesArray(0)
Dim In As InputStream = File.OpenInput(Dir, FileName)
File.Copy2(In, out)
Dim lastSlash As Int = FileName.LastIndexOf("/")
If lastSlash > -1 Then
FileName = FileName.SubString(lastSlash + 1)
End If
Dim su As StringUtils
Dim j As HttpJob
j.Initialize("file", Me)
j.PostBytes(link & "?type=file&name=" & su.EncodeUrl(FileName, "UTF8"), _
out.ToBytesArray)
End If
End Sub
Sub
JobDone(j As HttpJob)
If j.Success Then
ToastMessageShow("Success: " & j.GetString, False)
Log("Success: " & j.GetString)
Else
ToastMessageShow("Error: " & j.ErrorMessage, True)
Log("Error: " & j.ErrorMessage)
End If
j.Release
End Sub
Sub
Activity_Resume
End Sub
Sub
Activity_Pause (UserClosed As Boolean)
End Sub