Example #1
0
        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());
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }