Beispiel #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();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Save Storage Item
        /// </summary>
        /// <param name="storageItem">Storage Item</param>
        /// <param name="exists">Exists</param>
        public void Save(IStorageItem storageItem, bool exists = false)
        {
            var path    = storageItem.RelativePath.Replace('\\', '/');
            var request = new PutObjectRequest()
            {
                BucketName  = this.bucket,
                Key         = path,
                CannedACL   = S3CannedACL.Private,
                Timeout     = 3600000,
                MD5Digest   = storageItem.MD5,
                ContentType = storageItem.ContentType,
            };

            using (var stream = new MemoryStream(storageItem.GetData()))
            {
                request.InputStream = stream;
                using (var response = this.client.PutObject(request))
                {
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Save Storage Item
        /// </summary>
        /// <param name="storageItem">Storage Item</param>
        /// <param name="exists">Exists</param>
        public void Save(IStorageItem storageItem, bool exists = false)
        {
            Directory.CreateDirectory(System.IO.Path.GetDirectoryName(this.Path));

            File.WriteAllBytes(this.Path, storageItem.GetData());
        }
Beispiel #4
0
        /// <summary>
        /// Save Storage Item
        /// </summary>
        /// <param name="storageItem">Storage Item</param>
        /// <param name="exists">Exists</param>
        public void Save(IStorageItem storageItem, bool exists = false)
        {
            Directory.CreateDirectory(System.IO.Path.GetDirectoryName(this.Path));

            File.WriteAllBytes(this.Path, storageItem.GetData());
        }
Beispiel #5
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();
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// Save Storage Item
        /// </summary>
        /// <param name="storageItem">Storage Item</param>
        /// <param name="exists">Exists</param>
        public void Save(IStorageItem storageItem, bool exists = false)
        {
            var path = storageItem.RelativePath.Replace('\\', '/');
            var request = new PutObjectRequest()
            {
                BucketName = this.bucket,
                Key = path,
                CannedACL = S3CannedACL.Private,
                Timeout = 3600000,
                MD5Digest = storageItem.MD5,
                ContentType = storageItem.ContentType,
            };

            using (var stream = new MemoryStream(storageItem.GetData()))
            {
                request.InputStream = stream;
                using (var response = this.client.PutObject(request))
                {
                }
            }
        }