public static bool BlobExists(HtmlBlobType htmlBlobType, string htmlBlobId, Uri uri) { string blobName = HtmlBlob.ConstructBlobName(htmlBlobType, htmlBlobId, uri); CloudBlockBlob cloudBlockBlob = HtmlBlob.CloudBlobContainer.GetBlockBlobReference(blobName); return(cloudBlockBlob.Exists()); }
public static void SaveBlob(HtmlBlobType htmlBlobType, string htmlBlobId, Uri uri, string html) { string blobName = HtmlBlob.ConstructBlobName(htmlBlobType, htmlBlobId, uri); CloudBlockBlob cloudBlockBlob = HtmlBlob.CloudBlobContainer.GetBlockBlobReference(blobName); cloudBlockBlob.UploadText(html); }
public static void GetAndStoreHtmlBlobs(HtmlBlobType htmlBlobType, Dictionary <Uri, string> items, [Optional] bool forceOverwrite) { foreach (Uri uri in items.Keys) { HtmlBlob.GetAndStoreHtmlBlob(htmlBlobType, items[uri], uri, forceOverwrite); } }
public static void GetAndStoreHtmlBlob(HtmlBlobType htmlBlobType, string htmlBlobId, Uri uri, [Optional] bool forceOverwrite) { if (forceOverwrite == false && HtmlBlob.BlobExists(htmlBlobType, htmlBlobId, uri)) { // Blob exists and we don't want to force an overwrite so do nothing return; } string htmlBlob = HtmlBlob.GetHtmlPage(uri); if (!String.IsNullOrWhiteSpace(htmlBlob)) { HtmlBlob.SaveBlob(htmlBlobType, htmlBlobId, uri, htmlBlob); } }
public static string RetrieveBlob(HtmlBlobType htmlBlobType, string htmlBlobId, Uri uri, bool getIfNotExists = false) { // Get the blob if it doesn't exist if (getIfNotExists == true) { // This method will not do anything if the blob already exists HtmlBlob.GetAndStoreHtmlBlob(htmlBlobType, htmlBlobId, uri); } string blobName = HtmlBlob.ConstructBlobName(htmlBlobType, htmlBlobId, uri); CloudBlockBlob cloudBlockBlob = HtmlBlob.CloudBlobContainer.GetBlockBlobReference(blobName); string result = null; try { result = cloudBlockBlob.DownloadText(); } catch (System.AggregateException e) { HtmlBlob.PrintGetHtmlPageException(cloudBlockBlob.SnapshotQualifiedUri, e); bool is404Exception = e.InnerExceptions.Where(ie => ie.GetType() == typeof(HttpRequestException) && ie.Message.IndexOf("404 (Not Found).", StringComparison.InvariantCultureIgnoreCase) >= 0).Any(); if (!is404Exception) { //throw; } } catch (Exception e) { HtmlBlob.PrintGetHtmlPageException(cloudBlockBlob.SnapshotQualifiedUri, e); //throw; } return(result); }
private static string ConstructBlobName(HtmlBlobType htmlBlobType, string htmlBlobId, Uri uri) { string blobName = String.Join("/", HtmlBlob.nhlBlobNamePrefix, htmlBlobType.ToString(), htmlBlobId, uri.RemoveHttpFromUri()); return blobName; }
public static string RetrieveBlob(HtmlBlobType htmlBlobType, string htmlBlobId, Uri uri, bool getIfNotExists = false) { // Get the blob if it doesn't exist if (getIfNotExists == true) { // This method will not do anything if the blob already exists HtmlBlob.GetAndStoreHtmlBlob(htmlBlobType, htmlBlobId, uri); } string blobName = HtmlBlob.ConstructBlobName(htmlBlobType, htmlBlobId, uri); CloudBlockBlob cloudBlockBlob = HtmlBlob.CloudBlobContainer.GetBlockBlobReference(blobName); string result = null; try { result = cloudBlockBlob.DownloadText(); } catch (System.AggregateException e) { HtmlBlob.PrintGetHtmlPageException(cloudBlockBlob.SnapshotQualifiedUri, e); bool is404Exception = e.InnerExceptions.Where(ie => ie.GetType() == typeof(HttpRequestException) && ie.Message.IndexOf("404 (Not Found).", StringComparison.InvariantCultureIgnoreCase) >= 0).Any(); if (!is404Exception) { //throw; } } catch (Exception e) { HtmlBlob.PrintGetHtmlPageException(cloudBlockBlob.SnapshotQualifiedUri, e); //throw; } return result; }
public static void GetAndStoreHtmlBlobs(HtmlBlobType htmlBlobType, Dictionary<Uri, string> items, [Optional] bool forceOverwrite) { foreach (Uri uri in items.Keys) { HtmlBlob.GetAndStoreHtmlBlob(htmlBlobType, items[uri], uri, forceOverwrite); } }
public static bool BlobExists(HtmlBlobType htmlBlobType, string htmlBlobId, Uri uri) { string blobName = HtmlBlob.ConstructBlobName(htmlBlobType, htmlBlobId, uri); CloudBlockBlob cloudBlockBlob = HtmlBlob.CloudBlobContainer.GetBlockBlobReference(blobName); return cloudBlockBlob.Exists(); }
private static string ConstructBlobName(HtmlBlobType htmlBlobType, string htmlBlobId, Uri uri) { string blobName = String.Join("/", HtmlBlob.nhlBlobNamePrefix, htmlBlobType.ToString(), htmlBlobId, uri.RemoveHttpFromUri()); return(blobName); }