While implementing few use cases, I realized that there is no cumulative post that explains how attachments can be Attached, Uploaded and downloaded to/from repository (Amazon S3 as example). Attached are two comprehensive use cases. I hope this helps other developers who may be doing similar use cases.
Use case 1: This describes following
1. Create a PDF using HTMLtoPDF.
2. Get base64 stream of PDF and upload it to repository (Amazon S3).
3. Link it to case so that it is available to users as a downloadable.
Use case 2: This describes following.
1. Create a button to browse documents from PC.
2. Get base64 stream of document from Directory on server and upload it to repository(Amazon S3).
3. Link it to case so that it is available as downloadable
Accessory information: Pega can read documents from S3 using file listener by specifying the file path as below on the properties tab