If I have a file in FMS like C:\Program Files\FileMaker\FileMaker Server\Data\Documents\file1.pdf
What is the correct syntax to download that file using a hosted copy of FMP?
The effective way to do this is to get the fileminto a container on the server first with PSOS. You can do this with insert from URL using “file://“.
Return the record PK for the container to the client or the entire file itself in a variable.
Sorry for not being clear.
The INSERT FROM URL transfer is to a micro-service, not to a container. (container comes later)
What's with the Field Missing error?
To insert into a container, the container field in question must actually appear on the layout.
Thanks. Yes, it is.
Sometimes putting a file into a container using a "file://" works and sometimes it doesn't.
Set Variable [ $fileList ; Value: List(layout1::ResponseText) ]
Set Variable [ $counter ; Value: 1 ]
Set Variable [ $found ; Value: False ]
# Simple example only to extract a single returned file (filter for a directory)
If [ Right(GetValue ( $fileList ; $counter ) ; 1) <> "/" and Right(GetValue ( $fileList ; $counter ) ; 1) <> "\\" ]
Insert from URL [ Select ; With dialog: Off ; layout1::FileFromServer ; "file://" & Get ( DocumentsPath) & "/" & Middle(GetValue(List ( layout1::ResponseText ); $counter); Position ( layout1::ResponseText ; "UploadZips" ; 1 ; 1 ); Length ( layout1::ResponseText )) ]
Set Variable [ $found ; Value: True ]
Set Variable [ $counter ; Value: $counter + 1 ]
Exit Loop If [ $found = True ]
No way I know of to actually debug this script running on the server to see what's going on so this debug is taking a long time.
I created a small sample FMP app that demonstrates the issue. However to run it, you would need FMS and have to setup at least one documents file path so you could see what's (not) happening...If you have time, please PM me and I'll get this sample app to you. Thx.
Here is another example which does not work.
In the script that's done on the server via PSOS, I also tried this simplest example:
Set Variable [ $fileList ; Value: List(layout1::ResponseText) ] // works
Set Variable [ $counter ; Value: 1 ]
Set Variable [ $fileToUse ; Value: GetValue($fileList; $counter) ]
Note: $fileToUse is now: "C:\Program Files\FileMaker\FileMaker Server\Data\Documents\test_me\70\Simple File.txt"
Yet, the following INSERT FROM URL FAILS in PSOS script:
Insert from URL [ Select ; With dialog: Off ; layout1::FileFromServer ; "file://" & $fileToUse ]
On the server itself, we have the following valid path: C:\Program Files\FileMaker\FileMaker Server\Data\Documents\test_me\70
In that final 70 directory, we have the expected file:
So why is this File INSERT FROM URL Failing (silently with no helpful logging message)??
I also tried:
Sorry, but that doesn't answer the basic question since I've already tried all these permutations.
I think I'll go ahead and submit an issue on this as it shouldn't be this difficult.
Make your PSOS end with an Exit Script [ $FileToUse ]. Set $FileToUse using that long formula you have ( ""file://" & Get ( DocumentsPath) & "/" & Middle(GetValue(List ( layout1::ResponseText ); $counter); Position ( layout1::ResponseText ; "UploadZips" ; 1 ; 1 ); Length ( layout1::ResponseText ))" )
You need to know how that is being evaluated. By adding "$FileToUse" to the calculation you're using, you'll be able to see how it is actually being evaluated on the server. Then, when control returns to the script that calls the PSOS, use
Set Variable [ $HowThePathLooks ; Get ( ScriptResult ) ]
Use a Show Custom Dialog to show you what the server came up with. Show Custom Dialog. "The path looks like " & $HowThePathLooks
Retrieving data ...