Searching a working example of std_fileupload weblet
Searching a working example of std_fileupload weblet
Hi,
I am looking for a working example of the std_fileupload weblet in a WAM. Has anyone ever used it?
I am looking for a working example of the std_fileupload weblet in a WAM. Has anyone ever used it?
--
Regards,
Joop Roseboom
Regards,
Joop Roseboom
-
René Houba
- Posts: 220
- Joined: Thu Nov 26, 2015 7:03 am
Re: Searching a working example of std_fileupload weblet
Hi Joop,
I created a little example for you.
Attached a ZIP file that you can import.
I tested this on my laptop, so I uploaded the files to C:\TEMP, you can change this of course to an IFS path.
The source of the WAM: I know you still have LANSA V14 SP2.
This weblet in V15 has a new parameter "acceptFileTypes" with a default value of "any".
When you start the example, you will see: See next REPLY for more screenshots......
I created a little example for you.
Attached a ZIP file that you can import.
I tested this on my laptop, so I uploaded the files to C:\TEMP, you can change this of course to an IFS path.
The source of the WAM: I know you still have LANSA V14 SP2.
This weblet in V15 has a new parameter "acceptFileTypes" with a default value of "any".
When you start the example, you will see: See next REPLY for more screenshots......
- Attachments
-
- FileUploadExample.zip
- (17.21 KiB) Downloaded 2519 times
-
René Houba
- Posts: 220
- Joined: Thu Nov 26, 2015 7:03 am
Re: Searching a working example of std_fileupload weblet
You can select one or more files:
And can select the Upload icon per file:
-
René Houba
- Posts: 220
- Joined: Thu Nov 26, 2015 7:03 am
Re: Searching a working example of std_fileupload weblet
I uploaded them to my C:\TEMP directory:
Kind regards,
René
René
Re: Searching a working example of std_fileupload weblet
Thanks René! I'll give it a try!
--
Regards,
Joop Roseboom
Regards,
Joop Roseboom
Re: Searching a working example of std_fileupload weblet
Hi René,
I've given it a try but it does not seem to work unfortunately. This is (part of) my code:
I'm also wondering what the call to built-in function TRANSFORM_FILE is for? In the help https://docs.lansa.com/14/en/LANSA015/C ... m_file.htm it says it only works with text data files.
We also don't have #FILEUPFLD in our repository. Can you give the details on that field?
I've given it a try but it does not seem to work unfortunately. This is (part of) my code:
Code: Select all
Define Field(#BIFRetCode) Type(*Char) Length(2) Label('BIF return code')
Define Field(#FilePath) Type(*String) Length(256) Desc('Full upload path from web')
Define Field(#FileNaam) Type(*String) Length(256) Desc('File name')
* ------------------------------------------------------------------------------
* Define Working Lists
* ------------------------------------------------------------------------------
Def_List Name(#FileData) Fields(#Std_Strng) Type(*Working) Entrys(*Max)
* ------------------------------------------------------------------------------
* Define Web-Maps
* ------------------------------------------------------------------------------
Web_Map For(*Both) Fields(#FileData) Options(*PERSIST)
Web_Map For(*Both) Fields((#GRFTYP *HIDDEN) (#GRFRID *HIDDEN))
* ==============================================================================
* W E B R O U T I N E S
* ==============================================================================
* ------------------------------------------------------------------------------
* Event handling
* ------------------------------------------------------------------------------
Webroutine Name(uHandleEvent)
* Register the event that will execute when clicking on the Push button 1 in this filter as wam event number 1.
#avFrameworkManager.avRegisterEvent Named(UB_PUSHB1.CLICK) SignalAsWAMEvent(1)
* Standard WAM initialisation.
#avFrameworkManager.avInitializeWAM Type(COMMAND) Invoker(#com_owner) LIstManager(#avListManager) HandlerManager(#ThisHandler) FastPartManager(#FastPart)
#avFrameworkManager.avHandleWAMEvent AnchorBlock(#vf_framew) Event(#vf_event) DesignMode(#vf_framed) Skin(#VF_Frames) MetaTag(#vf_elmeta) TOF(#vf_elxtof) N01(#vf_elxn01) N02(#vf_elxn02) N03(#vf_elxn03) N04(#vf_elxn04) N05(#vf_elxn05) N06(#vf_elxn06) N07(#vf_elxn07) N08(#vf_elxn08) N09(#vf_elxn09) N10(#vf_elxn10) A01(#vf_elxA01) A02(#vf_elxA02) A03(#vf_elxA03) A04(#vf_elxA04) A05(#vf_elxA05) A06(#vf_elxA06) A07(#vf_elxA07) A08(#vf_elxA08) A09(#vf_elxA09) A10(#vf_elxA10) SSIName(#VF_FRAMEI)
Endroutine /* uHandleEvent */
* ----------------------------------------------------------------------------------
* Afhandeling files uploading
* ----------------------------------------------------------------------------------
Webroutine Name(WR) Response(*JSON)
Web_Map For(*Both) Fields(#FilePath #FileNaam)
#avFrameworkManager.avRecordTraceAValue Component(#COM_OWNER) Event('Webroutine WR - FilePath = ') AValue(#FilePath)
Use Builtin(OV_FILE_SERVICE) With_Args('CHECK_FILE' #FilePath) To_Get(#BIFRetCode)
If (#BIFRetCode = 'OK')
Use Builtin(TRANSFORM_FILE) With_Args(#FileData #FilePath T I) To_Get(#BIFRetCode)
#FileNaam := 'C:\Temp\uploaded' + *DATETIMEC.Trim + #FilePath.Substring( #FilePath.LastPositionOf( "." ) )
Use Builtin(OV_FILE_SERVICE) With_Args('COPY_FILE' #FilePath #FileNaam) To_Get(#BIFRetCode)
Message Msgtxt('Upload was succesful')
Else
Message Msgtxt('Upload was not successful')
Endif
Endroutine /* WR */
We also don't have #FILEUPFLD in our repository. Can you give the details on that field?
--
Regards,
Joop Roseboom
Regards,
Joop Roseboom
-
René Houba
- Posts: 220
- Joined: Thu Nov 26, 2015 7:03 am
Re: Searching a working example of std_fileupload weblet
Hi Joop,
The export file (if you do an import in VL) contains the field as well: It's a BLOB field: Also:
Are you testing this on your iSeries? If so: I see in your source that you use C:\temp path. That is my example, if you run on iSeries that should be a valid IFS path of course.
The export file (if you do an import in VL) contains the field as well: It's a BLOB field: Also:
Are you testing this on your iSeries? If so: I see in your source that you use C:\temp path. That is my example, if you run on iSeries that should be a valid IFS path of course.
-
René Houba
- Posts: 220
- Joined: Thu Nov 26, 2015 7:03 am
Re: Searching a working example of std_fileupload weblet
Hi Joop,
And the TRANSFORM_FILE is not needed (was a test from my site
)
Kind regards,
René
And the TRANSFORM_FILE is not needed (was a test from my site
Kind regards,
René
Re: Searching a working example of std_fileupload weblet
René, thanks (again)! I'll give it another try today.
--
Regards,
Joop Roseboom
Regards,
Joop Roseboom
Re: Searching a working example of std_fileupload weblet
Hi René,
I tried again today and so far I can click on the Select Files button and select 1 or more files. But as soon as I click on the Upload button behind one of the the filenames, I get an "Invalid web request" error. I have selected a valid IFS path for the files to be uploaded to. Do you have any suggestions as to what I can try?
I tried again today and so far I can click on the Select Files button and select 1 or more files. But as soon as I click on the Upload button behind one of the the filenames, I get an "Invalid web request" error. I have selected a valid IFS path for the files to be uploaded to. Do you have any suggestions as to what I can try?
--
Regards,
Joop Roseboom
Regards,
Joop Roseboom
Re: Searching a working example of std_fileupload weblet
Hi Joop
Were you able to make it work?
My example is not that clean, but it maybe can help you.
I created a table that stores the images as blob, called it TestImages with two fields: TIMEC (key), and STD_BLOB
Created a Test webroutine in the wam, dragged a fileupload weblet to it, properties were set as:
For the webroutine OBJECT1Routine:
You can check if the blob is stored or not just checking the TESTImages file.
If so, you know that the the fileupload weblet is working.
Now, if you want to see the blob as an image in a web page for example, a dirty example here,
I just added a webroutine showLastBlob, and added a button in the first webroutine to call it.
in the showLastBlob, I added just added in the XSL:
and the code of the showLastBlob is:
notice that the routine assumes you have a temp folder inside your images folder, and depending if you are in the IBM or in Windows, copy the file using the copy obj() todir() command from the IBM or the simple copy of windows, from the temporary folder that contains temporarily the blob fields, to a permanent web folder, in this case in /images/temp/ , so you can show the image in the web.
Were you able to make it work?
My example is not that clean, but it maybe can help you.
I created a table that stores the images as blob, called it TestImages with two fields: TIMEC (key), and STD_BLOB
Created a Test webroutine in the wam, dragged a fileupload weblet to it, properties were set as:
Code: Select all
name: STD_BLOB
uploadWrName: OBJECT1Routine
submitExtraFields: (press (...) then STD_BLOB is there)
maxNUmberOfFields: 1Code: Select all
Webroutine Name(OBJECT1Routine) Response(*JSON)
Web_Map For(*INPUT) Fields(#STD_BLOB)
#TIMEC := *TIMEC
Insert Fields(#TIMEC #STD_BLOB) To_File(TESTImages)
EndroutineIf so, you know that the the fileupload weblet is working.
Now, if you want to see the blob as an image in a web page for example, a dirty example here,
I just added a webroutine showLastBlob, and added a button in the first webroutine to call it.
in the showLastBlob, I added just added in the XSL:
Code: Select all
<img src="{key('field-value', 'STD_STRNG')}"> IMAGE </img>Code: Select all
Webroutine Name(showLastBlob)
Web_Map For(*BOTH) Fields(#STD_STRNG)
* read the last blob
Select Fields(#std_blob) From_File(TESTImages) Options(*BACKWARDS)
Leave
Endselect
* Copy the blob from temporary blob folder to public web folder /images/temp/
Define Field(#FilePath) Type(*CHAR) Length(256) Decimals(0)
Define Field(#FileExtension) Type(*CHAR) Length(256) Decimals(0)
Define Field(#FileName) Type(*CHAR) Length(256) Decimals(0)
Define Field(#OV_TO) Type(*CHAR) Length(256)
#FilePath := #STD_BLOB.FileName
#STD_NUM := #FilePath.LastPositionOf( '.' )
If (#STD_NUM > 0)
#FileExtension := #FilePath.Substring( #STD_NUM, 256 )
Else
#FileExtension := *blanks
Endif
If (*OSAPI = "IBMI")
#STD_STRNG := "copy obj('" + #FilePath + "') todir('" + *root_dir + "/WebServer/Images/temp/') replace(*yes)"
Use Builtin(system_command) With_Args("S" #STD_STRNG) To_Get(#std_num)
#FileName := #FilePath.Substring( (#FilePath.CurChars - #FilePath.Reverse.PositionOf( "/" ) + 2), #FilePath.Reverse.PositionOf( "/" ) )
Else
#STD_STRNG := 'cmd/c ' + 'copy "' + #FilePath + '" ' + *root_dir + '\WebServer\images\temp\'
#FileName := #FilePath.Substring( (#FilePath.CurChars - #FilePath.Reverse.PositionOf( "\" ) + 2), #FilePath.Reverse.PositionOf( "\" ) )
Endif
Use Builtin(system_command) With_Args("S" #STD_STRNG) To_Get(#std_num)
#STD_STRNG := "/images/temp/" + #FileName
EndroutineRe: Searching a working example of std_fileupload weblet
Hi Dino,
Thanks for your reply. Unfortunately I still can not get it to work. Even if I keep the webroutine more or less empty it keeps giving of this Invalid web request error. I think it might have something to do with our webserver or something. I will have to look into that.
Thanks for your reply. Unfortunately I still can not get it to work. Even if I keep the webroutine more or less empty it keeps giving of this Invalid web request error. I think it might have something to do with our webserver or something. I will have to look into that.
--
Regards,
Joop Roseboom
Regards,
Joop Roseboom
-
René Houba
- Posts: 220
- Joined: Thu Nov 26, 2015 7:03 am
Re: Searching a working example of std_fileupload weblet
Hi Joop,
One other thing to consider is that my test was done on my laptop in LANSA V15, but I implemented this at another customer in the Netherlands on the iSeries without any problem. They have LANSA V15 as well.
I know that you still have LANSA V14 SP2.
Kind regards,
René
One other thing to consider is that my test was done on my laptop in LANSA V15, but I implemented this at another customer in the Netherlands on the iSeries without any problem. They have LANSA V15 as well.
I know that you still have LANSA V14 SP2.
Kind regards,
René
Re: Searching a working example of std_fileupload weblet
Hi René,
I have tried it on our test partition which has Lansa V15 installed. But it doesn't work there either. I wonder if there needs to be configured something in the webserver to be able to receive files? Like some authority? And I also think we don't have a 'standard' installation concerning webserver configuration etc.
I have tried it on our test partition which has Lansa V15 installed. But it doesn't work there either. I wonder if there needs to be configured something in the webserver to be able to receive files? Like some authority? And I also think we don't have a 'standard' installation concerning webserver configuration etc.
--
Regards,
Joop Roseboom
Regards,
Joop Roseboom