• 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.

Determining or chaning the vvIn_file Filename

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

  • Determining or chaning the vvIn_file Filename

    Is there a way to see what the filename is of the file being uploaded using vvin_file()? I want to take the filename and append a timestamp to it (ie. myfile.txt to myfile-20150408-140522.txt). I just created a custom copy of EXUPLOAD1 to see if I could vvin_char('filename') and it retrieved nothing. So I pulled up the the console in my web browser (Chrome) and went to the network tab. I re-uploaded the file and I noticed this in the request payload:

    Code:
    ------WebKitFormBoundaryW5niHvEeuM0bOVjr
    Content-Disposition: form-data; name="sid"
    
    2581E634D09C6CA7BC940269C25CB4B73A6287CE6D6CC4A8FDE14BD8019C64A6
    ------WebKitFormBoundaryW5niHvEeuM0bOVjr
    Content-Disposition: form-data; name="app"
    
    115
    ------WebKitFormBoundaryW5niHvEeuM0bOVjr
    Content-Disposition: form-data; name="pgm"
    
    EXUPLOAD1
    ------WebKitFormBoundaryW5niHvEeuM0bOVjr
    Content-Disposition: form-data; name="file"; filename="myfile.txt"
    Content-Type: image/jpeg
    
    
    ------WebKitFormBoundaryW5niHvEeuM0bOVjr--
    How do I gain access (in RPG) to the hidden web variables specified in the form for this view? My main objective is to simply modify the existing filename so I can append a unique identifier to it (in case they upload another one).

    ---edit---
    Just did a little digging/debugging and found that globalInDS.fileName within vvin_file contains the filename. Is there a way for the RPG program called by vvupload.pgm to gain access to this variable? I tried adding globalInDS.fileName to my RPG program and it came back as undefined (I assume it's encapsulated within vvin)
    Last edited by rkanemeier; 04-08-2015, 02:16 PM.

  • #2
    Any parameters submitted for an upload are saved to the session variables. The name of file is held is given a special session variable name though. You can retrieve the name of the file by using the following:

    Code:
    vvUtility_getSessVar('VVUPLOAD_fileName');

    Comment


    • #3
      Sean,

      I just put your code into the EXUPLOAD1 program and recompiled and ran through debug. vvUtility_getSessVar('VVUPLOAD_fileName') is returning blank. I changed the parm to VVUPLOAD_filename and it still doesnt' work. I'm on Valence 4.1.20150211.0.

      RPG code:


      Code:
      filename = vvUtility_getSessVar('VVUPLOAD_fileName');               
                                                                          
      vvIn.path = %char(%trim(vvUtility_getValenceSetting('ROOT_PATH'))) +
                  'resources/uploads';                                    
      successMsg = 'The file has been successfully uploaded to '+         
                   %trim(vvIn.path);                                      
      vvIn_file(vvIn:successMsg);                                         
      *inlr=*on;
      I just added the following code thinking it would help:

      Code:
      sessionDS = vvUtility_getSessVar(VVSESSVAR);
      It did not help.

      I also just looked up my session id in Active Users and can confirm that I see a record for VVUPLOAD_fileName in VVSESSVARS for my session id (I cannot see what it says but I can see it has a value).
      Last edited by rkanemeier; 04-08-2015, 02:53 PM.

      Comment


      • #4
        Ray, after executing the vvIn_file, go into the Nitro File Editor app call up file VVSESSDATA [correction: VVSESSVARS]. Do you see the VVUPLOAD_fileName record in there?

        Comment


        • #5
          Forgot to mention, vvupload will call your program passing in the session Id as the only parameter. Accept this parameter in your program and use it as the second parameter on your call to vvUtility_getSessVar.

          Comment


          • #6
            Rob,

            Did you mean check file VVSESSVARS? VVSESSDATA doesn't have anything like that. VVSESSVARS does have a VUPLOAD_fileName record and there is something there but it seems encoded.

            Sean,

            Thanks for the info. I assume you mean the web variable "sid" that is posted with the form/file? Just do a vvin_char on sid?

            Comment


            • #7
              Yes, I believe Rob meant VVSESSVARS. On your program that processes the upload (the program that VVUPLOAD will call) code it to accept one parameter. This will be this "sid", it is 64A. Then use that parameter to pass as the second parm to vvUtility_getSessVar.

              Comment


              • #8
                .... Hopefully you guys didn't read that. ;-/

                Sean, thanks for your response. Checking into it now.
                Last edited by rkanemeier; 04-14-2015, 03:13 PM.

                Comment


                • #9
                  In the program to process the download you have to do the following:

                  - accept a parameter as 64A (This will be the session id). For example purposes...let's name it "inSid"
                  - localFilename = vvUtility_getSessVar('VVUPLOAD_fileName':inSid);

                  Comment


                  • #10
                    Sean,

                    That worked. I had created a response above that showed it wasn't working, but I was using UPLOAD_fileName instead of VVUPLOAD_fileName.

                    Thanks!

                    I take it we cannot use the VVSESSVAR DS to pull back user information during this upload process? It seems sessionDS = vvUtility_getSessVar(VVSESSVAR) is not working. I'm trying to rename the uploaded file in case 2 users are uploading at the same time. So I'm appending the userid to the beginning of the file name (with a time stamp as well).
                    Last edited by rkanemeier; 04-14-2015, 04:05 PM.

                    Comment

                    Working...
                    X