Quantcast
Channel: Process Integration (PI) & SOA Middleware
Viewing all articles
Browse latest Browse all 741

Trick to upload a file onto PI server - Single Stack

$
0
0

Dear Friends,

 

With the new secure connectivity add-on, we have the capability of PGP encryption using the PGP module. The keystore available in NWA is not able to store the PGP key files and they need to be stored in the server.

 

Now I am a lazy person and I find it a hard job to go speak with the basis consultant and convince him to place the file in the server and on the folder which I want

 

So what's the alternative? A simple java mapping program with the file which I want to be uploaded to server zipped with the archive. Create a dummy interface mapping and just execute it. The file gets uploaded into the folder which is given as a parameter in the mapping. Code snippet below for the transform method.

 

@Override

public void transform(TransformationInput arg0, TransformationOutput arg1)

throws StreamTransformationException {

try {

String fileName = arg0.getInputParameters().getString("fileName");

String filePath = arg0.getInputParameters().getString("filePath");

InputStream inputStream = getClass().getResourceAsStream(fileName);

File f = new File(filePath + java.io.File.separator + fileName);

OutputStream out = new FileOutputStream(f);

byte buf[] = new byte[1024];

int len;

while ((len = inputStream.read(buf)) > 0)

out.write(buf, 0, len);

out.close();

inputStream.close();

getTrace().addWarning("All is Well!!!");

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

}

Well I guess similar logic could be used to download file from PI server and load it to an FTP. May be I will write that some other day.

 

Please do let me know of further improvements and I will try and incorporate into a better addin.


Viewing all articles
Browse latest Browse all 741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>