I'm new with Apex. I'm downloading images from web with Apex that i'd like to add in Files. Already i'm just adding images to Attachment.
//Download image
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint(linkImg);
req.setTimeout(60000);
req.setMethod('GET');
HttpResponse res = h.send(req);
Blob bodyImg = res.getBodyAsBlob();
//Add image to Attachment
Attachment att = new Attachment(Name = nameImg, Body =
bodyImg, ContentType = 'image/png',
ParentId=parentid);
insert att;
Is there a way to add document directly in Files or convert/link automatically Attachment to Files ?