Question
PayPal
IN
Last activity: 21 Sep 2015 0:47 EDT
Is there a OOTB way to get size of an uploaded PDF document ?
Hello All,
I wanted to know if there is any OOTB way to get the size of a PDF being uploaded into PRPC. I want to restrict based on the size and explicitly get the size in MB/Bytes.
Thanks,
Nishan
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Updated: 21 Sep 2015 0:47 EDT
PayPal
IN
Thank you all for the response and the pointers. From what I could infer, there is no OOTB way to achieve this in 63sp1.In 7.x, it can be done via the System setting "pyMaxDragDropAttachSizeMB" as pointed out by Pankaj Rawal. I have developed the below java snippet that would use pega api to decrypt the uploaded file and give the size by calculating the number of bytes in the byte array.
The prconfig environment vaiable setting is useful if we want to restrict it system wide and it gives a 403 response from server stating the file size is larger. A simple page-set-message after calculating the size using the below snippet works.
java.util.HashMap hmFileInfo = pega_rules_utilities.uploadFile(); String strAttachStream = (String)hmFileInfo.get( "FileData" ); byte file [] = null; file = Base64Util.decodeToByteArray(strAttachStream); FileSize_S = file.length/1024; oLog.infoForced("FileSize is : "+FileSize_S);
PayPal
IN
Hi Chunzi,
The prconfig xml setting here is applicable across PRPC and not specific to users. Is there a way we can restrict it specific to a screen or a type of file ?
I checked up attachment category rule but it does not give an option to restrict based on size rather only on privilege.
Regards,
Nishan
PayPal
IN
For checking size and hence to restrict, I can use the below code as a starting point. But are you aware of any OOTB way ?
<%
int Result=0;
String strDDPageName = "AllAttachments";
ClipboardPage cpDrgDrpFU = tools.findPage( strDDPageName );
ClipboardProperty pResults = cpDrgDrpFU.getProperty( "pxResults" );
Result= pResults.size();
%>
<html>
<%= Result%>
</html>
Pegasystems Inc.
JP
I don't think there is a OOTB way to conditionally restrict uploaded file size. You need to hack it yourself.
Pegasystems Inc.
IN
There is a System setting for this purpose pyMaxDragDropAttachSizeMB.
This setting will restrict user to upload file more than specified size.
PayPal
IN
I dont think this works for file upload .. it works for drag drop alone.
Pegasystems Inc.
IN
This setting works for both.
PayPal
IN
Thanks a lot Pankaj for the response. Is this present in 6.3sp1 ? I just cross checked the system setting again in my 63sp1, environment and didnt find it. I also went ahead and created one setting with the same name pyMaxDragDropAttachSizeMB but it doesnt seem to work.
Pegasystems Inc.
IN
Unfortunately no
This setting was exposed in later releases.
Pegasystems Inc.
IN
PayPal
IN
thanks phani
Pegasystems Inc.
GB
Hi Nishan,
In addition to the 'fail-safe' of preventing a file-upload exceeding a threshold; it looks like HTML5 has some new facilities to check the file before it is uploaded.
So if you are using recent generation browsers you might be able to use these new tricks: I haven't tried this myself I have to add !
See here: http://stackoverflow.com/questions/1601455/how-to-check-file-input-size-with-jquery
(JQuery ships with newer PRPC versions OOTB : but I'm not sure about whether the version is correct for the post above - you may have to import a later version of JQuery to get this to work)
Cheers
John
Accepted Solution
Updated: 21 Sep 2015 0:47 EDT
PayPal
IN
Thank you all for the response and the pointers. From what I could infer, there is no OOTB way to achieve this in 63sp1.In 7.x, it can be done via the System setting "pyMaxDragDropAttachSizeMB" as pointed out by Pankaj Rawal. I have developed the below java snippet that would use pega api to decrypt the uploaded file and give the size by calculating the number of bytes in the byte array.
The prconfig environment vaiable setting is useful if we want to restrict it system wide and it gives a 403 response from server stating the file size is larger. A simple page-set-message after calculating the size using the below snippet works.
java.util.HashMap hmFileInfo = pega_rules_utilities.uploadFile(); String strAttachStream = (String)hmFileInfo.get( "FileData" ); byte file [] = null; file = Base64Util.decodeToByteArray(strAttachStream); FileSize_S = file.length/1024; oLog.infoForced("FileSize is : "+FileSize_S);
-
BHANU KIRAN THAVVA