Hi @arpitv27529355 @ka786 I have figured it out.
jcr:mimeType was incorrect on below path for generated file stream.
/content/dam/myprojectfolder/mytextfile.txt/jcr:content/renditions/original/jcr:content
To fix this updated the code provided mimeType as "text/plain", below is the code
AssetManager assetManager=resourceResolver.adaptTo(AssetManager.class);
assetManager.createAsset(fileName, stream, "text/plain", true);