示例#1
0
        /// <summary>
        /// Save Storage Item
        /// </summary>
        /// <param name="source">Storage Item</param>
        /// <param name="exists">Exists</param>
        public void Save(IStorageItem source, bool exists = false)
        {
            if (exists)
            {
                if (createSnapShot)
                {
                    this.blob.CreateSnapshot();

                    Trace.WriteLine(string.Format("Created snapshot of blob: '{0}'.", this.blob.Uri));
                }
            }

            if (source.Exists())
            {
                this.blob.Properties.ContentType = source.ContentType;
                //// Currently there is a bug in the library that this isn't being stored or retrieved properly, this will be compatible when the new library comes out
                this.blob.Properties.ContentMD5 = source.MD5;
                this.blob.UploadByteArray(source.GetData());

                if (!string.IsNullOrWhiteSpace(source.MD5))
                {
                    this.blob.Metadata[MD5MetadataKey] = source.MD5;
                    this.blob.SetMetadata();
                }
            }
        }
        private static async Task TestItemRoundtrip(IStorageItem item)
        {
            var expectedContent = GetRandomItemContent();

            Assert.False(await item.Exists());
            Assert.Null(await item.Get());
            Assert.False(await item.Delete());
            await item.PutText(expectedContent);

            var actualContent = await item.GetText();

            Assert.Equal(expectedContent, actualContent);

            Assert.True(await item.Exists());
            Assert.True(await item.Delete());
            Assert.False(await item.Exists());
            Assert.Null(await item.Get());
            Assert.False(await item.Delete());
        }
示例#3
0
        /// <summary>
        /// Save Storage Item
        /// </summary>
        /// <param name="source">Storage Item</param>
        /// <param name="exists">Exists</param>
        public void Save(IStorageItem source, bool exists = false)
        {
            if (exists)
            {
                if (createSnapShot)
                {
                    this.blob.CreateSnapshot();

                    Trace.WriteLine(string.Format("Created snapshot of blob: '{0}'.", this.blob.Uri));
                }
            }

            if (source.Exists())
            {
                this.blob.Properties.ContentType = source.ContentType;
                //// Currently there is a bug in the library that this isn't being stored or retrieved properly, this will be compatible when the new library comes out
                this.blob.Properties.ContentMD5 = source.MD5;
                this.blob.UploadByteArray(source.GetData());

                if (!string.IsNullOrWhiteSpace(source.MD5))
                {
                    this.blob.Metadata[MD5MetadataKey] = source.MD5;
                    this.blob.SetMetadata();
                }
            }
        }