is there any OOTB way to set file data on pyContents of D_pxNewFile data page? By default it seems RAP file data will be present on .pyStream (java.io.InputStream) property of D_pxNewFIle (sets in pzPublishArtifactWrapper activity).
Do we have any option to set the data on pyContents or do we need to do it manually in pyNewFile extension activity?
You will need to set it manually in a similar way as pzPublishArtifactWrapper does. I'm not aware of any OOTB way to get a stream or file contents as a string. There's an activity named @baseclass.pxPublishArtifact which does what you're asking, but it has flawed support for the repository API and will cause issues with custom repositories - it might serve as a good reference though.
You shouldn't need to set data on pyContents in the pyNewFile extension activity because the file data should be passed in as an activity input.
I hope this answers your question. Let me know if I can be of any additional help.