You can use SDriveTools API class to create a public access link, after configuring S-URL from S-Drive Configuration tab. To create a public access link using API class call the following method:
cg.SDriveTools.createPublicAccessLink(fileIds, objectFileName, objectId, objectName, objectRelationshipName, isUpdatable, isDeletable, isCreatable, 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 String objectId: Id of parent object, i.e. for account files it is id of Account record
@param String objectName: Name of the parent object, i.e. for account files it is "Account"
@param String objectRelationshipName: The name of the relationship field that between parent and file objects. e.g. relationship field name of between account & account files is "Account__r"
@param Boolean isUpdatable: It enables/disables file edit feature for public user
@param Boolean isDeletable: It enables/disables file delete feature for public user
@param Boolean isCreatable: It enables/disables file upload & create new folder feature for public user
@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