B4J Question [ABMaterial] How to download text file from remote server

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

My ABMaterial App run in the VPS(not local). How to download text file from VPS to local(browser side) ?
 

Cableguy

Expert
Licensed User
Longtime User
I was under the impression that any link pointing to a file would automatically become a download on client (browser) side... have you tried it?
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
I want to download file use a sub not to click a link.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
You need to do an Ajax call.

B4X:
Sub btn1_Clicked(Target As String)
    page.CallAjax("0001", "../uploads/myCSV.csv", "GET", "", "")
End Sub

Sub Page_AjaxError(uniqueId As String, error As String)
    Log(error)
End Sub

Sub Page_AjaxResult(uniqueId As String, result As String)
    Log(result)
End Sub

Alwaysbusy
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
I try to use following code to download a csv file from VPS
B4X:
File.Writestring(fd1,filename,csv.ToString)
page.CallAjax("0001", jyString.Slash($"..\uploads\${filename}"$), "GET", "", "")

its event can work but it cann't downalod anything to browser side :eek:
B4X:
Sub Page_AjaxResult(uniqueId As String, result As String)
    Log(result)
End Sub
B4X:
use,description,device,register,poll,start,points,interval,steady,operator,datatype,var1,token,msg
false,LINEGATE_連線失敗!,tcpslave,9,200,0,1,10,0,92,-1,,LINEgate1,TEXT,,{D} {T}{NL}INE連線失敗
false,LINEGATE_連線成功!,tcpslave,9,200,0,1,3,0,94,-1,,LINEgate1,TEXT,,{D} {T}{NL}?LINEGATE 已連線成功!
false,L5_AHU_4F6_FS,tcpslave,0,0,1,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 防火開關
false,L5_AHU_4F6_SD,tcpslave,0,0,2,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 偵煙開關
false,L5_AHU_4F6_TR1,tcpslave,0,0,3,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 故障跳脫
false,L5_AHU_4F6_FS1,tcpslave,0,0,4,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 防火開關
false,L5_AHU_4F6_SD1,tcpslave,0,0,5,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 偵煙開關
false,L5_AHU_4F6_TR2,tcpslave,0,0,6,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 故障跳脫
false,L5_AHU_4F6_FS2,tcpslave,0,0,100,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 防火開關
false,L5_AHU_4F6_SD2,tcpslave,0,0,101,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 偵煙開關
false,L5_AHU_4F6_TR3,tcpslave,0,0,102,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 故障跳脫
false,L5_AHU_4F6_FS3,tcpslave,0,0,103,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 防火開關
false,L5_AHU_4F6_SD3,tcpslave,0,0,105,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 偵煙開關
false,L5_AHU_4F6_TR4,tcpslave,0,0,110,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 故障跳脫
false,L5_AHU_4F6_FS4,tcpslave,0,0,111,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 防火開關
false,L5_AHU_4F6_SD4,tcpslave,0,0,112,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 偵煙開關
false,L5_AHU_4F6_TR5,tcpslave,0,0,96,1,1,100,1,-1,,LINEgate1,TEXT,,96 AHU_4F6 故障跳脫
false,L5_AHU_4F6_FS5,tcpslave,0,0,97,1,1,100,1,-1,,LINEgate1,TEXT,,97 AHU_4F6 防火開關
false,L5_AHU_4F6_SD5,tcpslave,0,0,52,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 偵煙開關
false,L5_AHU_4F6_TR6,tcpslave,0,0,53,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 故障跳脫
false,L5_AHU_4F6_FS6,tcpslave,0,0,54,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 防火開關
false,L5_AHU_4F6_SD6,tcpslave,0,0,56,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 偵煙開關
false,L5_AHU_4F6_TR7,tcpslave,0,0,57,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 故障跳脫
false,L5_AHU_4F6_FS7,tcpslave,0,0,60,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 防火開關
false,L5_AHU_4F6_SD7,tcpslave,0,0,62,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 偵煙開關
false,L5_AHU_4F6_TR8,tcpslave,0,0,63,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 故障跳脫
false,L5_AHU_4F6_FS8,tcpslave,3,0,10,1,1,100,3,1,10,LINEgate1,TEXT,,AHU_4F6 防火開關
false,L5_AHU_4F6_SD8,tcpslave,3,0,12,1,1,100,3,1,12,LINEgate1,TEXT,,AHU_4F6 偵煙開關
false,L5_AHU_4F6_TR9,tcpslave,3,0,13,1,1,100,3,1,13,LINEgate1,TEXT,,AHU_4F6 故障跳脫
false,L5_AHU_4F6_F1S,tcpslave,3,0,14,1,1,100,3,1,14,LINEgate1,TEXT,,AHU_4F6 防火開關
false,L5_AHU_4F6_S1D,tcpslave,3,0,20,1,1,100,3,1,20,LINEgate1,TEXT,,{R}AHU_4F6 偵煙開關
false,L5_AHU_4F6_T1R,tcpslave,3,0,21,1,1,100,3,1,21,LINEgate1,TEXT,,AHU_4F6 故障跳脫
false,L5_AHU_4F6_F2S,tcpslave,3,0,23,1,1,100,3,1,23,LINEgate1,TEXT,,AHU_4F6 防火開關
false,L5_AHU_4F6_S2D,tcpslave,3,0,50,1,1,100,3,1,50,LINEgate1,TEXT,,{R}AHU_4F6 偵煙開關
false,L5_AHU_4F6_T2R,tcpslave,0,0,300,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 故障跳脫
false,L5_AHU_4F6_F3S,tcpslave,0,0,301,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 防火開關
false,L5_AHU_4F6_S3D,tcpslave,0,0,302,1,1,100,1,-1,,LINEgate1,TEXT,,AHU_4F6 偵煙開關
 
Upvote 0
Top