Sub JobDone(Job As HttpJob)
Private mCallback As Object
Private mEvent As String
Private mDebug As Boolean: mDebug = True
job_success = Job.success
If Job.Success Then
Dim res As String
res=Job.GetString
Select Job.JobName
Case "filedownload"
Dim OutStream As OutputStream
Dim pth As String = GetPath(Job.Tag)
Dim fle As String = GetFilename(Job.Tag)
Dim name As String
Log("DownloadReady: "&Job.Tag)
Log("DestPath: "&pth)
'Where pth = File.Combine(File.DirRootExternal, "Download")
LogColor("DestFilename: "&fle,Colors.cyan)
OutStream = File.OpenOutput(pth, fle, False) ' Job.Tag is read to set the Original Filename we specify earlier in the creation of the Job
File. Copy2(Job.GetInputStream,OutStream) ' save the file
OutStream.Close
Dim dm As DownloadManager
Try
Dim extension As String = fle.SubString2(fle.LastIndexOf("."), fle.Length)
Log("extension: " & extension)
If Starter.map_mime_types.get(extension) <> Null Then
Dim application_mime As String = Starter.map_mime_types.get(extension)
Else
Dim application_mime As String = "application/" + extension
End If
Log("application_mime:" & application_mime)
dm.AddCompletedDownload(fle, file_type_name , True , application_mime ,File.Combine(pth,fle),File.Size(pth,fle),True)
Catch
Dim error_info As String = "serv_dropbox downloadManager: application_mime" & application_mime & " - [Error]: " & Job.ErrorMessage
LogColor(error_info , Colors.argb(196, 255, 140, 0))
End Try
End Select
Else
LogColor("Error: " & Job.ErrorMessage,Colors.Red)
End If
CallSubDelayed(Me, "job_done_complete")
End Sub