We recommend using createPublicLink instead.

You can use SDriveTools API class to create a public download link, after configuring S-URL from S-Drive Configuration tab. To create a public download link using API class call the following method:

cg.SDriveTools.createPublicDownloadLink(fileIds, objectFileName, expirationDate, password, IpRange);

The method signature is explained as follows:
@param List<String> fileIds: List of ids of files & folders
@param String objectFileName: Full object name of the file, e.g. 'cg_AccountFile_c'
@param Datetime expirationDate: Expire date for the link
@param String password: The minimum password length should be 4 characters
@param String IpRange: Two IP addresses as string separated by a "-" dash