public static bool TryParse(string value, bool isContainerBinding, out BlobPath path) { path = null; if (value == null) { return false; } int slashIndex = value.IndexOf('/'); if (!isContainerBinding && slashIndex <= 0) { return false; } if (slashIndex > 0 && slashIndex == value.Length - 1) { // if there is a slash present, there must be at least one character before // the slash and one character after the slash. return false; } string containerName = slashIndex > 0 ? value.Substring(0, slashIndex) : value; string blobName = slashIndex > 0 ? value.Substring(slashIndex + 1) : string.Empty; path = new BlobPath(containerName, blobName); return true; }
public void ToString_BlobPath_ReturnsExpectedResult() { BlobPath path = BlobPath.Parse("container/blob", false); Assert.Equal("container/blob", path.ToString()); path = BlobPath.Parse("container", true); Assert.Equal("container", path.ToString()); path = new BlobPath("container", null); Assert.Equal("container", path.ToString()); }
public IReadOnlyDictionary<string, object> CreateBindingData(BlobPath actualBlobPath) { if (actualBlobPath == null) { return null; } // The path source may be a container name only. In that case, ignore the blob name for determining a match. if (actualBlobPath.ToString() == ToString() || (String.IsNullOrEmpty(_innerPath.BlobName) && actualBlobPath.ContainerName == _innerPath.ContainerName)) { // Some consumers understand null as "blob didn't match". Return an empty dictionary instead for that case. return new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase); } else { return null; } }
public IReadOnlyDictionary<string, object> CreateBindingData(BlobPath actualBlobPath) { if (actualBlobPath == null) { return null; } // Containers must match if (!String.Equals(ContainerNamePattern, actualBlobPath.ContainerName, StringComparison.OrdinalIgnoreCase)) { return null; } // Pattern is container only if (String.IsNullOrEmpty(BlobNamePattern)) { return new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase); } return _template.CreateBindingData(actualBlobPath.ToString()); }
public static bool TryParse(string value, out BlobPath path) { if (value == null) { path = null; return false; } int slashIndex = value.IndexOf('/'); // There must be at least one character before the slash and one character after the slash. if (slashIndex <= 0 || slashIndex == value.Length - 1) { path = null; return false; } string containerName = value.Substring(0, slashIndex); string blobName = value.Substring(slashIndex + 1); path = new BlobPath(containerName, blobName); return true; }
private static bool TryParseAndValidate(string value, out string errorMessage, out BlobPath path, bool isContainerBinding = false) { BlobPath possiblePath; if (!TryParse(value, isContainerBinding, out possiblePath)) { errorMessage = "Blob identifiers must be in the format 'container/blob'."; path = null; return false; } if (!BlobClient.IsValidContainerName(possiblePath.ContainerName)) { errorMessage = "Invalid container name: " + possiblePath.ContainerName; path = null; return false; } // for container bindings, we allow an empty blob name/path string possibleErrorMessage; if (!(isContainerBinding && string.IsNullOrEmpty(possiblePath.BlobName)) && !BlobClient.IsValidBlobName(possiblePath.BlobName, out possibleErrorMessage)) { errorMessage = possibleErrorMessage; path = null; return false; } errorMessage = null; path = possiblePath; return true; }
private static bool TryParseAndValidate(string value, out string errorMessage, out BlobPath path, bool isContainerBinding = false) { BlobPath possiblePath; if (!isContainerBinding && TryParseAbsUrl(value, out possiblePath)) { path = possiblePath; errorMessage = null; return(true); } if (!TryParse(value, isContainerBinding, out possiblePath)) { errorMessage = $"Invalid blob path specified : '{value}'. Blob identifiers must be in the format 'container/blob'."; path = null; return(false); } if (!BlobClientExtensions.IsValidContainerName(possiblePath.ContainerName)) { errorMessage = "Invalid container name: " + possiblePath.ContainerName; path = null; return(false); } // for container bindings, we allow an empty blob name/path string possibleErrorMessage; if (!(isContainerBinding && string.IsNullOrEmpty(possiblePath.BlobName)) && !BlobClientExtensions.IsValidBlobName(possiblePath.BlobName, out possibleErrorMessage)) { errorMessage = possibleErrorMessage; path = null; return(false); } errorMessage = null; path = possiblePath; return(true); }
public FixedBlobPathSource(BlobPath innerPath) { _innerPath = innerPath; }
private static bool TryParseAndValidate(string value, out string errorMessage, out BlobPath path) { BlobPath possiblePath; if (!TryParse(value, out possiblePath)) { errorMessage = "Blob identifiers must be in the format 'container/blob'."; path = null; return(false); } if (!BlobClient.IsValidContainerName(possiblePath.ContainerName)) { errorMessage = "Invalid container name: " + possiblePath.ContainerName; path = null; return(false); } string possibleErrorMessage; if (!BlobClient.IsValidBlobName(possiblePath.BlobName, out possibleErrorMessage)) { errorMessage = possibleErrorMessage; path = null; return(false); } errorMessage = null; path = possiblePath; return(true); }
private static bool TryParseAndValidate(string value, out string errorMessage, out BlobPath path) { BlobPath possiblePath; if (!TryParse(value, out possiblePath)) { errorMessage = "Blob identifiers must be in the format 'container/blob'."; path = null; return false; } if (!BlobClient.IsValidContainerName(possiblePath.ContainerName)) { errorMessage = "Invalid container name: " + possiblePath.ContainerName; path = null; return false; } string possibleErrorMessage; if (!BlobClient.IsValidBlobName(possiblePath.BlobName, out possibleErrorMessage)) { errorMessage = possibleErrorMessage; path = null; return false; } errorMessage = null; path = possiblePath; return true; }
public BoundBlobPath(BlobPath innerPath) { _innerPath = innerPath; }