/// <summary> /// Recreates a BLOB in the store to allow for restarting multiple BLOB uploads on a /// <see cref="ThingBase"/>. /// </summary> /// /// <param name="blobName"> /// The name of the BLOB. It can be <see cref="string.Empty"/> but cannot be <b>null</b>. /// </param> /// /// <param name="contentType"> /// The content type of the BLOB. /// </param> /// /// <param name="hashInfo"> /// The hash information for the BLOB. /// </param> /// /// <param name="blobUrl"> /// The HealthVault URL of the BLOB. /// </param> /// /// <returns> /// The <see cref="Blob"/> instance that was recreated in the store. /// </returns> /// /// <remarks> /// This overload is intended to allow the caller to recover from issues that may arise /// while uploading large BLOBs or many BLOBs for a <see cref="ThingBase"/>. /// If you have a large amount of data to upload, you can periodically save the state of /// the Blob instance (and BlobStream if necessary) and then use this method to recreate /// that same Blob instance in the store. /// </remarks> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="blobName"/> or <paramref name="contentType"/> is <b>null</b>. /// </exception> /// /// <exception cref="ArgumentException"> /// If a Blob with the same name already exists in the store. To update an existing Blob, /// remove the existing Blob and create a new one. /// </exception> /// public Blob NewBlob( string blobName, string contentType, BlobHashInfo hashInfo, Uri blobUrl) { Blob blob = new Blob(blobName, contentType, null, null, hashInfo, Record) { Url = blobUrl }; _blobs.Add(blobName, blob); _item.Sections |= ThingSections.BlobPayload; return(blob); }
internal void ParseXml(XPathNavigator nav) { XPathNodeIterator blobsIterator = nav.Select("blob"); foreach (XPathNavigator blobNav in blobsIterator) { string name = blobNav.SelectSingleNode("blob-info/name").Value; string contentType = blobNav.SelectSingleNode("blob-info/content-type").Value; XPathNavigator hashNav = blobNav.SelectSingleNode("blob-info/hash-info"); BlobHashInfo hashInfo = null; if (hashNav != null) { hashInfo = new BlobHashInfo(); hashInfo.Parse(hashNav); } string legacyContentEncoding = null; XPathNavigator encodingNav = blobNav.SelectSingleNode("legacy-content-encoding"); if (encodingNav != null) { legacyContentEncoding = encodingNav.Value; } string currentContentEncoding = null; XPathNavigator currentEncodingNav = blobNav.SelectSingleNode("current-content-encoding"); if (currentEncodingNav != null) { currentContentEncoding = currentEncodingNav.Value; } Blob blob = new Blob( name, contentType, currentContentEncoding, legacyContentEncoding, hashInfo, Record); XPathNavigator lengthNav = blobNav.SelectSingleNode("content-length"); if (lengthNav != null) { blob.ContentLength = lengthNav.ValueAsLong; } XPathNavigator base64Nav = blobNav.SelectSingleNode("base64data"); if (base64Nav != null) { blob.InlineData = Convert.FromBase64String(base64Nav.Value); } XPathNavigator urlNav = blobNav.SelectSingleNode("blob-ref-url"); if (urlNav != null) { blob.Url = new Uri(urlNav.Value); } _blobs[blob.Name] = blob; } }