Hey all!
Please note this is NOT an ABMaterial issue!
I have two systems running on a VPS. One is an ABMaterial app which uses the ABFileManager system and another is a light weight B4J webapp. The two systems need to share data (images) so I have set up a folder that both systems can access. Great so far and it works apart from one particular part.
To be able to display an image in the light webapp I need to copy it from the shared folder into a temp folder under www. Otherwise a browser can't access the file.
Here's my issue - the following code works a treat...
All well and good but I am concerned that simply using copy will cause issues if a lot of people are accessing photos like this.
As such I tried using the following -
This doesn't work as expected. The file does get copied into the temp folder however it no longer displays on screen. Even testing using a sleep(5000) before setting ImageToShow makes no difference. If I click the button again after a few seconds the image does show up (because it's already in the temp folder??).
I was under the impression that using the Wait.For would be the most sensible option.
Hints at what I'm doing wrong would be greatly appreciated!
Please note this is NOT an ABMaterial issue!
I have two systems running on a VPS. One is an ABMaterial app which uses the ABFileManager system and another is a light weight B4J webapp. The two systems need to share data (images) so I have set up a folder that both systems can access. Great so far and it works apart from one particular part.
To be able to display an image in the light webapp I need to copy it from the shared folder into a temp folder under www. Otherwise a browser can't access the file.
Here's my issue - the following code works a treat...
Using File.Copy:
Sub btnGet_Click (Params As Map) 'When the display image button is clicked.....
Dim ft1 As Future = text1.GetVal 'Get the text box value
Result.SetText("Getting photo : " & (ft1.Value)) 'Set the result param (a label) to "Getting Photo: " + whatever was typed
Dim ext As String = GetExtension(ft1.Value) 'Find the file extension (probably .jpg)
File.Copy("/home/domain/fdata/FileManager/photostore/", ft1.Value & ext, "/home/domain/lightapp.domain.co.uk/www/temp/", ft1.Value & ext)
Dim img As String = "<img src=""/temp/" & ft1.Value & ext & """ alt="""" width=""1200"" height=""800""> " 'Build an img html tag
Log ("img = " & img)
ImageToShow.Sethtml (img) 'Set the tag in the html code to our new one
Log ("Image Set")
End Sub
All well and good but I am concerned that simply using copy will cause issues if a lot of people are accessing photos like this.
As such I tried using the following -
Using File.CopyAsync with wait for:
Sub btnGet_Click (Params As Map) 'When the display image button is clicked.....
Dim ft1 As Future = text1.GetVal 'Get the text box value
Result.SetText("Getting photo : " & (ft1.Value)) 'Set the result param (a label) to "Getting Photo: " + whatever was typed
Dim ext As String = GetExtension(ft1.Value) 'Find the file extension (probably .jpg)
Wait For (File.CopyAsync("/home/domain/fdata/FileManager/photostore/", ft1.Value & ext, "/home/domain/lightapp.domain.co.uk/www/temp/", ft1.Value & ext)) Complete (Success As Boolean)
Log("Success: " & Success)
If Success Then
Dim img As String = "<img src=""/temp/" & ft1.Value & ext & """ alt="""" width=""1200"" height=""800""> " 'Build an img html tag
Log ("img = " & img)
ImageToShow.Sethtml (img) 'Set the tag in the html code to our new one
Log ("Image Set")
End If
End Sub
This doesn't work as expected. The file does get copied into the temp folder however it no longer displays on screen. Even testing using a sleep(5000) before setting ImageToShow makes no difference. If I click the button again after a few seconds the image does show up (because it's already in the temp folder??).
I was under the impression that using the Wait.For would be the most sensible option.
Hints at what I'm doing wrong would be greatly appreciated!
Last edited: