Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: 1 2 3 [4] 5 6 ... 10
 31 
 on: October 21, 2024, 08:21:54 am 
Started by Richard M. - Last post by Sebastien F.
Hello Richard,

Can you please provide the context (Genero version, Front-ends type and version, DB servers type and version, OSes type and version, etc) - We can better help if we know the context and such "details".

I was wondering why you need to convert the image data to base64.
I assume this is to send the images as plain text to the server?

About using IMPORT security:

While security.Base64.FromByte() needs the BYTE to be located in memory, DISPLAY BY NAME needs the BYTE to be located in a file:
https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_images_dynamic_images.html
Section "Displaying images contained in BYTE variables"

Since Genero BDL 2.51, we have util.Strings methods to encode/decode in base64.

https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_ext_util_Strings_methods.html

Except if you really need other APIs of the "security" module in your mobile app, I would just use the "util" package.

How to you plan to upload the photos to the central database?
Using RESTful Web Services?

What is the SQL CREATE TABLE DDL for the local mobile l_photos table and its equivalent on the server side to store photos?

Seb

 32 
 on: October 20, 2024, 02:35:14 am 
Started by Richard M. - Last post by Reuben B.
Re your error with security.base64.FromByte, note the Important tip in the documentation https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_gws_SecurityBase64_FromByte.html

 33 
 on: October 19, 2024, 11:46:09 pm 
Started by Richard M. - Last post by Richard M.
Plus you need to;

IMPORT security

 34 
 on: October 19, 2024, 11:42:24 pm 
Started by Richard M. - Last post by Richard M.
The below code now works.


-----------------------------;

FUNCTION LIB_CHT_GET_PHOTO(l_drop_id)                      #REMPHOTOS

CONSTANT l_vm_fn = "mypic.png"
DEFINE l_drop_id    INTEGER

DEFINE l_md_fn     STRING,
       l_image,
       l_byte      BYTE,
       l_photos    RECORD LIKE photos.*,
       b64string   STRING,
       l_text      TEXT

    --CALL LIB_CHT_TAKE_PHOTO() RETURNING l_filename
    TRY -- This front call may fail if the front-end is not a mobile device:
       CALL ui.Interface.frontCall( "mobile", "takePhoto", [], [l_md_fn] )
    CATCH
       MESSAGE "Cannot take photo: ", STATUS, " ", err_get(STATUS)
       LET l_md_fn = NULL
    END TRY
   
    IF l_md_fn IS NOT NULL THEN

        CALL fgl_getfile(l_md_fn, l_vm_fn)
        CALL security.Base64.LoadBinary(l_vm_fn) RETURNING b64string
 
        LOCATE l_text IN MEMORY
        LET l_text = b64string
       
        INITIALIZE l_photos TO NULL

        LET l_photos.photo_id   = NULL
        LET l_photos.drop_id    = l_drop_id
        LET l_photos.filename   = l_md_fn
        LET l_photos.photo      = l_text
        LET l_photos.sync       = "1"
   
        INSERT INTO photos VALUES l_photos.*

        LET l_photos.photo_id = LIB_SYS_GET_ID("photos")

    END IF

END FUNCTION

 35 
 on: October 17, 2024, 05:42:48 pm 
Started by Richard M. - Last post by Richard M.
Hi,

Thought i was on the right track with this but am getting an error at the 'CALL security.Base64.FromByte' line below,
saying 'Forms Statement Error -15701 Invalid Parameter'.

Can anyone help plz?    Thanks


FUNCTION LIB_CHT_GET_PHOTO()                      #REMPHOTOS

CONSTANT l_vm_fn = "mypic.tmp"
DEFINE l_md_fn     STRING,
       l_image     BYTE,
       l_photos    RECORD LIKE photos.*,
       b64string   STRING

    --CALL LIB_CHT_TAKE_PHOTO() RETURNING l_filename
    TRY -- This front call may fail if the front-end is not a mobile device:
       CALL ui.Interface.frontCall( "mobile", "takePhoto", [], [l_md_fn] )
    CATCH
       MESSAGE "Cannot take photo: ", STATUS, " ", err_get(STATUS)
       LET l_md_fn = NULL
    END TRY
   
    IF l_md_fn IS NOT NULL THEN

        CALL fgl_getfile(l_md_fn, l_vm_fn)
        LOCATE l_image IN FILE l_vm_fn
        CALL security.Base64.FromByte(l_image) RETURNING b64string
 
        INITIALIZE l_photos TO NULL

        LET l_photos.photo_id   = NULL
        LET l_photos.filename   = l_md_fn
        LET l_photos.photo      = b64string
        LET l_photos.sync       = "1"
   
        INSERT INTO photos VALUES l_photos.*

        LET l_photos.photo_id = LIB_SYS_GET_ID("photos")

    END IF

END FUNCTION


 36 
 on: October 17, 2024, 11:53:42 am 
Started by Benjamin G. - Last post by Benjamin G.
Hello,

When using WSAttachement to send a file to a GET request, how do I specify that the file is optional?
If I specify an existing file everything works fine. If I don't give a file (ficdia = NULL) it generates an infinite loop with code -8 (http error ...)


this is how the service is defined ...

PUBLIC FUNCTION getDownloadCustomerDiapo(head_numpro STRING ATTRIBUTES(WSHeader,WSOptional,WSName = ‘X-NUMPRODIS’)
                                        ,head_numcli STRING ATTRIBUTES(WSHeader,WSOptional,WSName = ‘X-NUMCLI’)
                                        ,head_diacli STRING ATTRIBUTES(WSHeader,WSOptional,WSName = ‘X-DIACLI’))
         ATTRIBUTES(WSGet
                   ,WSPath = ‘/download-customer-diapo’
                   ,WSDescription = ‘GET : Retrieves the zip file with the customer's slideshows’ ,WSRetCode = ‘GET : Retrieves the zip file with the customer's slideshows
                   ,WSRetCode = ‘201:Ok’
                   ,WSThrows = ‘400:Bad Request,500:Internal Server Error’)
        RETURNS (STRING ATTRIBUTES(WSMedia = ‘application/json’)
                ,STRING ATTRIBUTES(WSAttachment, WSMedia = ‘zip/*’))
  DEFINE jsn base.StringBuffer
  DEFINE ficdia STRING

  LET ficdia = prodisdbs.getDownloadCustomerDiapoPRODIS(jsn:=base.StringBuffer.create(),head_numpro,head_numcli,head_diacli)

  RETURN jsn.toString(),ficdia
END FUNCTION

thank you


 37 
 on: October 15, 2024, 04:13:13 pm 
Started by Roland W. - Last post by Reuben B.
Roland,

Have a read of https://4js.com/ask-reuben/ig-89/ for a discussion on UNBUFFERED.  Note the point "What you may also find is that you add fields to the dialog statement even though they are NOENTRY". 

A typical scenario is you have

Title (Label).     Code. (ButtonEdit).   Description (Label)

you might add the Description field to the INPUT statement so that any change in value of Description is reflected in the front-end without an explicit DISPLAY being required

Reuben

 38 
 on: October 15, 2024, 10:13:49 am 
Started by Roland W. - Last post by Roland W.
Sebastien,

OK, thanks for clarification. I'll try to adapt my code accordingly in the future.

Kind regards
Roland

 39 
 on: October 15, 2024, 08:56:40 am 
Started by Roland W. - Last post by Sebastien F.
Hello Roland,

Obviously, automatic variable / form field sync with UNBUFFERED attribute only concerns variables bound to form fields in your current dialog instruction.

You must append the variables to the INPUT BY NAME instruction to get this automatic sync.

Code
  1. INPUT BY NAME rec_customer.*, p_var ATTRIBUTES(UNBUFFERED, WITHOUT DEFAULTS)
  2.   ...
  3.   AFTER FIELD cust_name
  4.        LET p_var = "[",rec.cust_name,"]"
  5.        -- no need for DISPLAY BY NAME disp_var or DISPLAY disp_var1 TO field
  6.  

The corresponding form fields should be read-only (NOENTRY), or you should use non-editable form fields like LABEL.

But understand: You are not forced to review all your code to use this pattern. My suggestion about using UNBUFFERED was mainly for variables/form fields that are already part of your INPUT BY NAME.

Seb

 40 
 on: October 15, 2024, 08:31:08 am 
Started by Roland W. - Last post by Roland W.
Sebastien,

despite calling ui.dialog.setDefaultNnbuffered(true) and setting the UNBUFFERED attribute in the INPUT BY NAME statement, the automatic display of variables does not seem to work correctly or does this only apply to variables defined in an INPUT BY NAME?
I have defined some display fields in a form that contain values but are not explicitly displayed. If I omit the instruction DISPLAY BY NAME p_var, the value is not displayed. This is the reason why I use DISPLAY BY NAME in many cases, just to make sure that all values are displayed correctly. Unfortunately I haven't found out exactly why this is the case. Maybe I should open a support case for this.

Kind regards
Roland

Pages: 1 2 3 [4] 5 6 ... 10
Powered by SMF 1.1.21 | SMF © 2015, Simple Machines