Search code examples
catalystbyzohozohocatalystcatalystcloudscale

How to upload file from Deluge to Catalyst Filestore?


I have an creator application where the user uploads their resume for job application. I need to store that application in Catalyst FileStore so can someone share me any code snippet for uploading files using Deluge to Catalyst Filestore?


Solution

  • To upload files from your Deluge function, you need to get the File from your Deluge function and use catalyst filestore uploadFile API to send the files. You can get the necessary and how to upload file using Upload File API in Deluge using the below sample code snippet

    //create the headers for the Catalyst API's
    headerMap = Map();
    headerMap.put("Authorization","Zoho-oauthtoken {access_token}"); // create token with the required scope ZohoCatalyst.files.CREATE
    headerMap.put("Environment","Development");
    
    //get file from a source
    getFile = invokeurl
    [
        url :"https://img.zohostatic.com/catalyst/img/Face_Sample_Image-2-a4fa6f6a69.jpg"
        type :GET
    ];
    info getFile;
    
    // upload the file to the catalyst filestore
    filelist = List();
    filelist.add({"paramName":"code","content":getFile});
    filelist.add({"paramName":"file_name","content":"Face_Sample.jpg","stringPart":"true"});
    
    uploadFile = invokeurl
    [
    url :"https://api.catalyst.zoho.com/baas/v1/project/{project_id}/folder/{folder_id}/file"
        type :POST
        headers:headerMap
        files:filelist
    ];
    info uploadFile;
    
    
    return "";
    

    To know more info on Catalyst API you can follow the official help documentation from here.