how to make a downloaded file has file name + file extension in its name?
I want to download the file from 'File Upload' Field in Zoho CRM, after download the file then I will upload it to our own image server to create a download URL link. I wrote the code below.
but the problem is, the file name doesnt have file extension in it. so how to include a file name + file extension in the downloaded file name?
here is the code I use:
- // fetch CRM Deal Details
- v_Module = "Deals";
- v_dealID = DEAL_ID;
- v_Endpoint = "https://www.zohoapis.com/crm/v7/" + v_Module + "/" + v_dealID;
- r_DealDetails = invokeurl
- [
- url :v_Endpoint
- type :GET
- connection:"zoho_crm_connections"
- ];
- m_DealDetails = ifnull(r_DealDetails.get("data").toMap(),Map());
- if(!isNull(m_DealDetails.get("Product_Attachment")))
- {
- l_Files = List();
- for each m_FileUpload in m_DealDetails.get("Product_Attachment")
- {
- // get files from Zoho CRM
- v_FileDownloadUrl = "https://www.zohoapis.com/crm/v7/files?id=" + m_FileUpload.get("File_Id__s");
- v_FileName = m_FileUpload.get("File_Name__s"); // I am trying to get name and extension in here
- f_MyFile = invokeurl
- [
- url :v_FileDownloadUrl
- type :GET
- connection:"zoho_crm_connections"
- ];
- f_MyFile.setParamName("file_data");
- f_MyFile.setFileName(v_FileName); // set the file name in here but it doesnt work
- l_Files.add(f_MyFile);
- }
- if(!l_Files.isEmpty())
- {
- first_file = l_Files.get(0);
- // send first file only to Blueray Server
- bodyMap = Map();
- bodyMap.put("file_data",first_file);
- fileResponse = invokeurl
- [
- url :"https://myAPI.com/file/upload"
- type :POST
- parameters:bodyMap
- ];
- file_url = fileResponse.get("file_url");
- // update the field in deal module
- update = {"Product_Attachment_URL":file_url};
- zoho.crm.updateRecord("Deals",DEAL_ID,update);
- }
- }