I am using apex code to get file from url and able to insert it as attachment. I would like to know file name as well while insert ?
When I open link in chrome it save the file with file name.
public void getAndAttachFile(String recId, String fileId) {
// Instantiate a new http object
Http h = new Http();
// Instantiate a new HTTP request, specify the method (GET) as well as the endpoint
HttpRequest req = new HttpRequest();
req.setEndpoint('https://secure.basecone.com/Lookup/Download?externalId='+fileId);
req.setTimeout(60000);//sets maximum timeout
req.setMethod('GET');
HttpResponse res = h.send(req);
Blob body = res.getBodyAsBlob();
// **Here I want to set actual file name in Name field**
Attachment att = new Attachment(Name = fileId, Body = body, ParentId=recId);
insert att;
}