Question
LTIMindtree
PL
Last activity: 2 Nov 2022 6:05 EDT
How to place the uploaded files in separate folder in Pega server
Hi All,
I have a requirement that user will upload zip files and i need to place those files in dedicate folder which is in Pega server only.
Basically when we upload a file, it will store in temp directory but in my case i don't wanted to place files in temp directory and i wanted to place the file in separate folder.
Please help me how to achieve this.
Thanks, Uma Murala.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
NCS Pte. Ltd
SG
Hi @uma496: Default upload will place the file in the service export directory also it housekeep the service export.
Can you check if you can use Connect-File to place the uploaded file to a dedicated folder? (https://docs-previous.pega.com/sites/default/files/help_v73/rule-/rule-connect-/rule-connect-file/main.htm)
Note: In latest versions, connect file is deprecated and there are alternate for the same.
Thanks.
LTIMindtree
PL
Hi @ArulDevan,
Thanks for the response. correct me if i'm wrong, connect file is used to create a file and placing it in separate path right. but in my case i already have the file with me and need place those files in separate folder. will these can be done by using connect file? if yes what option i need to choose in connect-file method in the activity and what will be value in parameter field.
Please help.
Thanks, Uma Murala
Updated: 1 Nov 2022 6:16 EDT
NCS Pte. Ltd
SG
Hi @uma496: When you say you have the file, i hope you are referring to the file which you uploaded (and the same is available in your service export directory). This is a temporary location and it is not suggested to work with this temporary location. So the better way is to get the stream of the uploaded file, and use it to generate the file in the required location. You can use Write from clipboard property option for this. You can also use the write from work attachment if the file is already attached to case.
Please refer: https://docs-previous.pega.com/sites/default/files/help_v73/methods/connect-file/connect-file.htm
You can also achieve this using java methods. But it is not recommended.
Thanks.
LTIMindtree
PL
@ArulDevan Thanks a lot for the response.
I will explain my requirement clearly here.
Users will upload a zip file which is not a part of case attachments and this completely outside of a case. As we know that when we use pyFilePath control, the files will get stored in "file://web:/StaticContent/global/ServiceExport/". But the team has created a folder with name "CIP_BULK" in pega directory. So, when users upload zip file, we should place the file in CIP_BULK folder instead of service export directory. The file listener will monitor the CIP_BULK and it will process the zip file once it got placed. I was stucked at the placing the file in CIP_BULK foler.
Thanks, Uma Murala.
Wells Fargo
IN
Hi @uma496,
Another approach to your requirement is
Step 1: Need to create 1 repository rule, in that need to select the repository type as FileSystem.
---> in the Connection Details need to give the Your Directory folder
---> like E://CIP_BULK
Step 2: In the Application Definition rule need to give the repository name in the Integration tab.
Let me know if you need any other information
Thanks
Ravi Kumar.D
LTIMindtree
PL
Hi @RaviKumar(D),
If we add the repository instead default pega database in application definition rule then it will effect the entire application right. we have a separate screen as below for users to upload zip files and here these zip files needs to be placed in the CIP_BULK folder. all other scenario attachments should work as is.
Wells Fargo
IN
Hi @uma496,
Only Specific scenario [or specific screen], you need to store the attachments in that folder right?
If yes, then you need to customize your save attachments OOTB activity. Based on the when condition, you can store your attachment in a specified folder.
Thanks
Ravi Kumar.D
kalasalingam university
IN
@uma496 You have to customize your upload activity. The below code will put the file in the path. exPath is your export path, strFileName is your file name and fileType is your file extendtion. fileSource is the base64 string.
byte[] decodeContent = Base64Util.decodeToByteArray(fileSource);
PROutputStream fos = new PROutputStream(exPath+strFileName+fileType);
fos.write(decodeContent);
fos.close();
PRFile file = new PRFile(exPath+strFileName+fileType); strFileName =exPath+strFileName+fileType;