How to restrict File Types (extensions) from URL Object Properties When Adding Attachments Part I

First of all, I haven't tested this yet but I'm going to pretty soon :-). However, if someone wants to give it a go. Here it is.
You may have already know that, when attaching files using AddAttachement PeopleCode function, sometime we need to restrict certain file types that we don't want end-users to attach to our Peoplesoft system. Normal scenario we think that AddAttachement function will provide this for us. But guess what, even though AddAttachement function has a parameter names FileType, The function will not validate the FileTypes at all. In PeopleBooks it says;


In order to restrict certain file types obviously, we have to do something like this
&RETCODE = AddAttachment("RECORD://SOME_RECORD", &ATTACHSYSFILENAME, "", &ATTACHUSERFILE, 0);

If &RETCODE = 0 Then/* Returns Zero, when user clicks on OK with the valid File Path */
/* Then Check the file extension, if not throw an error msg and delete the file */
If Lower(Right(&ATTACHUSERFILE, 4)) <> ".txt" Then
MessageBox(0,"",0,0,"Your Message",0); /* You can only upload .txt files. */
&RETCODE1 = DeleteAttachment("RECORD://SOME_RECORD", &ATTACHUSERFILE); /* Delete file */
End-If;
But there is another way you can do this
Navigate to PeopleTools, Utilities, Administration, File Extension List page
Here you can set up list of file types, by file extensions which either can accept or reject when you do file attachments to your system. Once you have set up file extension list you have to specify FILE_EXT_LIST property in URL object using the URL maintenance page (PeopleTools, Utilities, Administration, URLs).

"You can restrict the file types that can be uploaded to or downloaded from your PeopleSoft system. The file type restrictions apply to the AddAttachment, DetachAttachment, MAddAttachment, and ViewAttachment functions. Allowable or disallowed file extensions are managed through a file extension list and through the FILE_EXT_LIST property of the URL object."

"This enables you to only upload the appropriate file types at runtime, and reject those file types you think may be suspicious, potentially harmful, or not appropriate for a particular call to a file-processing built-in PeopleCode function"

The most wanted Extension List Types are Inactive and Absolute, If you want to know more about the list types please follow the link http://docs.oracle.com/cd/E57990_01/pt853pbh2/eng/pt/tsvt/task_UsingAdministrationUtilities-07109c.html#ue3f0f90c-23f1-4110-aed1-29af14eff645
Hope this will help for you next implementation of file attachments. feel free to send any comments or suggestions.

SHARE

Ayesha Wee

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment