Hello everybody
Please help me,
I have a b4j server my user can download file from repository on dropbox, i get path from database then download file this works well, the problem happens when the second file is downloaded, 404 error is showed,I don't know why it happens
this is file link examples
https://jdb.rocas.co/drive?i=838986
https://jdb.rocas.co/drive?i=838987
https://jdb.rocas.co/drive?i=838988
this is my handler code
I appreciate your help
Please help me,
I have a b4j server my user can download file from repository on dropbox, i get path from database then download file this works well, the problem happens when the second file is downloaded, 404 error is showed,I don't know why it happens
this is file link examples
https://jdb.rocas.co/drive?i=838986
https://jdb.rocas.co/drive?i=838987
https://jdb.rocas.co/drive?i=838988
this is my handler code
B4J Server Dropbox File download:
Sub Handle(req As ServletRequest, resp As ServletResponse)
Procesar(req,resp)
StartMessageLoop
End Sub
Sub Procesar(req As ServletRequest,resp As ServletResponse)
Dim i As String = req.GetParameter("i")
i = req.GetParameter("i")
Dim con As SQL
con.Initialize("net.sourceforge.jtds.jdbc.Driver","jdbc:jtds:sqlserver://serverendpoint:1433/doc;instanceName=SQLEXPRESS;user=sa;password=password" )
Dim rs As ResultSet = con.ExecQuery2("{CALL usp_Ruta_Traer(?)}", Array(i))
If rs.NextRow Then
Dim n as string = rs.GetString("Ruta")
End If
If rs.IsInitialized Then rs.Close
If con.IsInitialized Then con.Close
If n <> "" Then
Dim j As HttpJob
Try
j.Initialize("", Me)
j.GetRequest.Timeout = 60000
j.PostString ("https://content.dropboxapi.com/2/files/download","")
j.GetRequest().SetContentType("application/octet-stream")
j.GetRequest().SetHeader ("Authorization", "Bearer XXXXXXXXXXXapidropboxXXXXXXXX")
j.GetRequest().SetHeader ("Dropbox-API-Arg", "{""path"":""" & n & """}")
' Log("Ruta: " & n)
Wait For(j) JobDone(j As HttpJob)
If j.Success Then
' Log("descargando archivo")
Dim b() As Byte=Bit.InputStreamToBytes(j.GetInputStream)
Dim x As Int = n.LastIndexOf("/")
n = n.SubString(x+1)
resp.SetHeader("Content-disposition", $"attachment; filename=${n}"$)
resp.SetHeader("Cache-Control", "no-cache, no-store") ' disables cache for HTTP 1.1
resp.SetHeader("Pragma", "no-cache") ' disables cache for HTTP 1.0
resp.ContentType="application/octet-stream"
resp.ContentLength=b.Length
Log(n)
resp.OutputStream.WriteBytes(b,0,b.Length)
resp.OutputStream.Close
Else
resp.Status=404
End If
Catch
resp.Status=404
Log(LastException)
End Try
j.Release
StopMessageLoop
End If
End Sub
I appreciate your help
Last edited: