unsignedDownloadUrlPrefix method

String unsignedDownloadUrlPrefix(
  1. String? cloudName,
  2. bool privateCdn,
  3. String? cname,
  4. bool secure,
  5. String? secureDistribution,
)

Implementation

String unsignedDownloadUrlPrefix(String? cloudName, bool privateCdn,
    String? cname, bool secure, String? secureDistribution) {
  var mutableCloudName = cloudName;
  var mutableSecureDistribution = secureDistribution;
  if (mutableCloudName != null) {
    if (mutableCloudName.startsWith("/")) {
      mutableCloudName = "/res$mutableCloudName";
    }
  }
  var sharedDomain = !privateCdn;
  String prefix;
  if (secure) {
    if (mutableSecureDistribution.isNullOrBlank) {
      if (privateCdn) {
        mutableSecureDistribution = "$mutableCloudName-res.cloudinary.com";
      } else {
        mutableSecureDistribution = akamaiSharedCDN;
      }
    }
    if (!sharedDomain) {
      sharedDomain = mutableSecureDistribution == akamaiSharedCDN;
    }
    prefix = 'https://$mutableSecureDistribution';
  } else if (!cname.isNullOrBlank) {
    prefix = 'http://$cname';
  } else {
    var protocol = 'http://';
    if (privateCdn) {
      mutableCloudName = '$mutableCloudName-';
    } else {
      mutableCloudName = '';
    }
    var res = 'res';
    var domain = '.cloudinary.com';
    prefix = protocol + mutableCloudName + res + domain;
  }
  if (sharedDomain) {
    // use original cloud name here:
    prefix += '/$cloudName';
  }
  return prefix;
}