I have a VF page(renderAs=pdf
) when I clicked on the custom button its generates pdf and saves that pdf in the attachment-related list. Now I want to save that pdf in File related list how to do this.
The below method save the pdf in Attachment related list
public PageReference attachPDF() {
PageReference pdfPage = Page.File_save;
Blob pdfBlob;
pdfPage.getParameters().put('id',a.Id);
if (!Test.isRunningTest()) {
pdfBlob = pdfPage.getContent();
} else {
pdfBlob = Blob.valueOf('Some Text for a boring PDF file...');
}
Attachment attach = new Attachment(parentId = a.Id, Name = 'Test'+'.pdf', body = pdfBlob);
insert attach;
Does anyone have an idea for the File?