• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

File upload CCSID

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • File upload CCSID

    Valence version: 6.1.20220706.0

    Trying to set the CCSID to 1208. It works if the file is .TXT, but will always upload as CCSID 37 if the file is .DAT.

    First the .txt document (this one works)...

    text_file.png

    text_file_ifs.png


    Rename the existing document from .txt to .dat and it will end up CCSID 37:

    dat_file.png
    dat_file_ifs.png


    Code:
    **free
    
    /copy qcpylesrc,vvHspec
    /include qcpylesrc,vvNabBtn
    
    // --------------------------------------------------------------
    // program start
    // --------------------------------------------------------------
    Initialize();
    Process();
    CleanUp();
    *inlr=*on;
    
    // --------------------------------------------------------------
    dcl-proc Process;
    
    vvIn.path = '/home/PBEHR/file_upload';
    vvIn.fileName = %char(%timestamp)
    + '_' + vvUtility_getSessVar('VVUPLOAD_fileName' : gSid);
    vvIn.ccsid = 1208;
    vvIn_file(vvIn : '*NULL');
    if vvIn.error <> *blanks;
    SetResponse('success' : 'false');
    return;
    endif;
    
    SetResponse('success' : 'true');
    
    end-proc Process;
    
    //================================================== ==================================
    // Valence copybook - DO NOT REMOVE
    //================================================== ==================================
    /include qcpylesrc,vvNabBtn

  • #2
    In order for the CCSID to be meaningful, the browser must report that the content-type of the upload contains text, otherwise Valence will assume it's a binary and ignore the CCSID. For example, an upload of .txt file the browser will normally report a content-type of text/plain. For a .dat file your browsee is probably reporting a content-type of application/octet-stream.

    Is it absolutely required for you to upload the file as a .dat? It would be better to upload it as .txt and then rename it so the content type is set correctly. If that's not possible you could upload it as .dat then do a CHGATR OBJ('/test.dat') ATR(*CCSID) VALUE(1208) on the backend after the upload is complete to set the CCSID.

    We could look at setting the CCSID on the file to the passed value, even if the browser reports it as binary, but I'm not sure if that would cause any other issues.
    Last edited by robert.swanson; 08-22-2022, 12:59 PM. Reason: typo

    Comment

    Working...
    X