/// <summary> /// Calculates the provider-specific remote path. /// </summary> /// <param name="Provider"></param> /// <returns></returns> public string GetRemoteContainerName(StorageProviderTypes Provider) { // Different cloud providers may have different naming rules for URIs. // Azure for example is all lowercase required. if (ID == Guid.Empty) { throw new InvalidOperationException("Cannot generate container name. Directory ID has not been set."); } if (Provider == StorageProviderTypes.Azure) { return(string.Format("{0}-directory-{1}", Constants.Logging.AppName, ID.ToString()).ToLower()); } else { throw new NotImplementedException("unexpected provider type: " + Provider.ToString()); } }
/// <summary> /// Returns the remote file name for the specified provider. /// </summary> /// <param name="provider">The cloud provider.</param> /// <returns>A </returns> public string GetRemoteFileName(StorageProviderTypes provider) { // Different cloud providers may have different naming rules for URIs. // Azure for example is all lowercase required. if (FileID == Guid.Empty) { throw new InvalidOperationException("Cannot generate file name. FileID has not been set."); } if (provider == StorageProviderTypes.Azure) { if (Filename.Contains(".")) { // file with an extension. var split = Filename.Split('.'); var extension = split[split.Length - 1]; // we only want alphanumeric characters in the uri // if for some reason windows allows special characters in the extension, dont use the extension in the uri then. var reg = new Regex("^[a-zA-Z0-9]*$"); if (extension.Length > 0 && reg.IsMatch(extension)) { return(string.Format("{0}-file-{1}-v{2}.{3}", Constants.Logging.AppName, FileID.ToString(), FileRevisionNumber, extension).ToLower()); } } // extensionless (or problematic extension) file. return(string.Format("{0}-file-{1}-v{2}", Constants.Logging.AppName, FileID.ToString(), FileRevisionNumber).ToLower()); } else { throw new NotImplementedException("unexpected provider type: " + provider.ToString()); } }