By the way, I follows Lahav’s direction (and a few others of you who tried to
say the same thing but it went clear over my head). I am very happy with the
solution.
I just needed a project method flagged with ‘execute on server’ in its
properties [or whatever you call it].
Then it was a very simple matter to ‘lookup’ the file on disk on the server and
retrieve its contents in a blob.
In short:
[Lib] contains .SubFolder, .FileName, .FileExt
Storage.folder_docLibrary.path is the ‘MAIN PATH’ to the library of documents
Then I just needed to write SVR_Lib_GetDocument ( [Lib]UUID ) which was
executed on 4D Server.
Because of all your kind tips, I like to just ‘give back’ by providing at least
some explanation of how I solved my problem.
—————————
// SVR_Lib_GetDocument ( [Lib]UUID ) --> BLOB of the document stored. Is an
empty BLOB if nothing could be retrieved
// NOTE: THIS IS EXECUTED ON 4D SERVER
C_TEXT($1) // the [Lib]UUID to look up
C_BLOB($0) // the RESULT we return to the 4D REMOTE
C_OBJECT($en_Lib) // the LIB record
C_OBJECT($obj_File) // the FILE( ) object
$en_Lib:=ds.Lib.get($1) // retrieve the $Lib record. Note that if it does not
exist, then the $en_Lib will be NULL
If ($en_Lib#Null) // if we have a true $en_Lib entity... (the .get() may not
actually retrieve one, possibly)
$obj_File:=File(Storage.folder_docLibrary.path+$en_Lib.SubFolder+$en_Lib.FileName+$en_Lib.FileExt)
If ($obj_File.isFile)
If ($obj_File.exists) // if it actually exists...
$0:=$obj_File.getContent()
End if
End if
End if
—————————
—— Chris
> On Apr 24, 2020, at 6:06 PM, Chris Belanger <[email protected]> wrote:
>
> Wow! I never knew that. Thanks for explaining, Lahav. — Chris
>
>> On Apr 24, 2020, at 4:52 PM, lists via 4D_Tech <[email protected]> wrote:
>>
>> Chris,
>>
>> Just create a regular method, mark it as "Execute on Server" in the method
>> properties, then call it just like any other method. You can return
>> anything you want in $0
>>
>> $myData:=ThisMethodRunOnServer(whatever)
>>
>> Just make sure to check that little box in the ThisMethodRunOnServer Method
>> properties and you are all done...
>>
>> Lahav
>>
>> -----Original Message-----
>> From: 4D_Tech <[email protected]> On Behalf Of Chris Belanger via
>> 4D_Tech
>> Sent: Friday, April 24, 2020 4:44 PM
>> To: 4D iNUG Technical <[email protected]>
>> Cc: Chris Belanger <[email protected]>
>> Subject: Re: 4D v18 — Need methodology to
>>
>> Hi Olivier,
>> I am looking for SIMPLE, alright.
>> I have looked at ‘execute on server’ but I do not see how it sends anything
>> to the client other than the process number (in $0).
>> What have I missing about it?
>> I used it in the past (when I made a ‘communicator’ subsystem in classic 4D)
>> but it involved ‘variable to variable’, pausing/resuming processes and the
>> like, and involved quite a bit of intricate programming.
>>
>> — Chris
>>
>>
>>> On Apr 24, 2020, at 5:27 AM, Olivier Flury via 4D_Tech
>>> <[email protected]> wrote:
>>>
>>> Maybe too simple for what you need to do, but have a look at the "execute
>>> on server" property for project methods.
>>>
>>> Create a method that is executed on server. It gets as $1 the id of the
>>> document you want to display on the client side. The method does everything
>>> to fetch the document from the directory on the server etc. and sends it to
>>> the client in $0.
>>>
>>> Keep in mind that this method (executed on server) behaves similar to a
>>> trigger method: you are read/write for all tables and you should have your
>>> own On Err Call method.
>>>
>>> Best,
>>>
>>> Olivier
>>>
>>> |||||| https://flury-software.ch/
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: 4D_Tech <[email protected]> Im Auftrag von Chris Belanger
>>> via 4D_Tech
>>> Gesendet: Freitag, 24. April 2020 10:57
>>> An: 4D iNUG Technical <[email protected]>
>>> Cc: Chris Belanger <[email protected]>
>>> Betreff: 4D v18 — Need methodology to
>>>
>>> I have a methodology of allowing clients to transfer documents that are
>>> thereafter stored by 4D Server in a ‘LIBRARY’ of system documents it
>>> maintains automatically. [these are not stored in the DB, but in a managed
>>> folder on disk.]
>>>
>>> I do this by:
>>> • Loading a system document into a BLOB, then using BASE64 ENCODE to store
>>> it in a TEXT field; —— thanks Peter Bozek for the tip on BASE64 ENCODE /
>>> DECODE!
>>> • the TRIGGER method (running on 4D server) unpacks it and creates /
>>> updates the files in its ‘Library’ directory on disk.
>>>
>>> Now I need to be able to retrieve the contents of these files for 4D
>>> [Client].
>>> I can display the files in a Web Area —> Thanks to Keith for the tip.
>>>
>>> ** But I am looking for a simple way to get 4D Server to ’send’ the data to
>>> the CLIENT (4D) upon request.
>>>
>>> In the past [since v12), I made elaborate ‘communicator’ stored routines to
>>> fudge it, but I have a feeling that now there are better ways to do it.
>>>
>>> I wish it was simple as:
>>> Request_Document ( $LibraryEntity ) —> Document Contents [retrieved from
>>> the library of user’s documents stored by 4D Server on disk]
>>>
>>> Any suggestions? Do I have to use Workers, or Stored Procedures, or
>>> something?
>>>
>>> Thank you, guys & gals,
>>>
>>> Chris Belanger
>>> **********************************************************************
>>> 4D Internet Users Group (4D iNUG)
>>> Archive: http://lists.4d.com/archives.html
>>> Options: https://lists.4d.com/mailman/options/4d_tech
>>> Unsub: mailto:[email protected]
>>> **********************************************************************
>>>
>>> **********************************************************************
>>> 4D Internet Users Group (4D iNUG)
>>> Archive: http://lists.4d.com/archives.html
>>> Options: https://lists.4d.com/mailman/options/4d_tech
>>> Unsub: mailto:[email protected]
>>> **********************************************************************
>>
>> **********************************************************************
>> 4D Internet Users Group (4D iNUG)
>> Archive: http://lists.4d.com/archives.html
>> Options: https://lists.4d.com/mailman/options/4d_tech
>> Unsub: mailto:[email protected]
>> **********************************************************************
>> **********************************************************************
>> 4D Internet Users Group (4D iNUG)
>> Archive: http://lists.4d.com/archives.html
>> Options: https://lists.4d.com/mailman/options/4d_tech
>> Unsub: mailto:[email protected]
>> **********************************************************************
>
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************