• Shubham Deshmukh 15
  • NEWBIE
  • 0 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

if it is pdf we can download using following code

 Pagereference pg = new Pagereference(url); 
                    Blob b = pg.getContentAsPDF(); //Here you can use getContent() too for another type of file
                    Attachment att = new Attachment(Name = extractedString, Body = b, ContentType = 'application/pdf', ParentId='a3KDx000000TXxBMAW');
                    insert (att);
If it is other than pdf like docx, image, recording etc etc. file is being inserted but it has nothing. Thanks in advance any help will be appreciated.

if it is pdf we can download using following code

 Pagereference pg = new Pagereference(url); 
                    Blob b = pg.getContentAsPDF(); //Here you can use getContent() too for another type of file
                    Attachment att = new Attachment(Name = extractedString, Body = b, ContentType = 'application/pdf', ParentId='a3KDx000000TXxBMAW');
                    insert (att);
If it is other than pdf like docx, image, recording etc etc. file is being inserted but it has nothing. Thanks in advance any help will be appreciated.

Hi

I have a url which contains xml file, if i click the click the url it will download the file to my local drive, instead of doing it manually i need to achieve this using apex class, i.e. the scheduled apex class download the file from a url and upload it to the custom object.

How to achieve this, anybody have worked this kind of scenario.

thanks
Dinesh