예제 #1
0
        public override void SetProperty(string path, PSObject propertyValue)
        {
            var r = AzureBlobPathResolver.ResolvePath(this.Client, path, skipCheckExistence: false);

            switch (r.PathType)
            {
            case PathType.AzureBlobBlock:
                r.Blob.FetchAttributes();
                MergeProperties(r.Blob.Metadata, propertyValue.Properties);
                r.Blob.SetMetadata();
                break;

            case PathType.AzureBlobDirectory:
                if (r.Parts.Count() == 1)
                {
                    r.Container.FetchAttributes();
                    MergeProperties(r.Container.Metadata, propertyValue.Properties);
                    r.Container.SetMetadata();
                }
                else
                {
                    throw new Exception("Setting metadata/properties for directory is not supported");
                }
                break;

            default:
                break;
            }
        }
예제 #2
0
        public override void RemoveItem(string path, bool recurse)
        {
            var r = AzureBlobPathResolver.ResolvePath(this.Client, path, skipCheckExistence: false);

            switch (r.PathType)
            {
            case PathType.AzureBlobDirectory:
                if (r.Parts.Count == 1)
                {
                    r.Container.Delete();
                    return;
                }

                this.DeleteDirectory(r.Directory, recurse);
                break;

            case PathType.AzureBlobBlock:
            case PathType.AzureBlobPage:
            case PathType.AzureBlobAppend:
                r.Blob.Delete();
                break;

            default:
                break;
            }
        }
예제 #3
0
        public override void GetProperty(string path, System.Collections.ObjectModel.Collection <string> providerSpecificPickList)
        {
            var r = AzureBlobPathResolver.ResolvePath(this.Client, path, skipCheckExistence: false);

            switch (r.PathType)
            {
            case PathType.AzureBlobBlock:
                r.Blob.FetchAttributes();
                this.RootProvider.WriteItemObject(r.Blob.Properties, path, false);
                this.RootProvider.WriteItemObject(r.Blob.Metadata, path, false);
                break;

            case PathType.AzureBlobDirectory:
                if (r.Directory == r.RootDirectory)
                {
                    r.Container.FetchAttributes();
                    this.RootProvider.WriteItemObject(r.Container.Properties, path, true);
                    this.RootProvider.WriteItemObject(r.Container.Metadata, path, true);
                }
                else
                {
                    //none to show
                }
                break;

            default:
                break;
            }
        }
예제 #4
0
        public override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            var r = AzureBlobPathResolver.ResolvePath(this.Client, path);

            switch (r.PathType)
            {
            case PathType.AzureBlobRoot:
                var shares = this.ListItems(path);
                foreach (CloudBlobContainer s in shares)
                {
                    this.RootProvider.WriteItemObject(s.Name, path, true);
                }
                break;

            case PathType.AzureBlobDirectory:
                ListAndHandle(r.Directory,
                              blobAction: b => this.RootProvider.WriteItemObject(b.Name, b.Parent.Uri.ToString(), false),
                              dirAction: d => this.RootProvider.WriteItemObject(d.Prefix, d.Parent.Uri.ToString(), false)
                              );
                break;

            case PathType.AzureBlobBlock:
            default:
                break;
            }
        }
예제 #5
0
        public override Stream CopyTo(string path, string name)
        {
            var r = AzureBlobPathResolver.ResolvePath(this.Client, path, skipCheckExistence: false);

            if (r.PathType == PathType.AzureBlobDirectory)
            {
                var blob = r.Directory.GetBlockBlobReference(name);
                return(blob.OpenWrite());
            }
            throw new Exception(path + " is not a directory");
        }
예제 #6
0
        public ICloudBlob GetBlob(string path, PathType expectedType)
        {
            var r = AzureBlobPathResolver.ResolvePath(this.Client, path, hint: expectedType);

            if (r.PathType == expectedType)
            {
                return(r.Blob);
            }

            return(null);
        }
예제 #7
0
        public override IContentReader GetContentReader(string path)
        {
            var r = AzureBlobPathResolver.ResolvePath(this.Client, path, skipCheckExistence: false);

            if (r.PathType == PathType.AzureBlobBlock ||
                r.PathType == PathType.AzureBlobPage ||
                r.PathType == PathType.AzureBlobAppend)
            {
                var reader = new AzureBlobReader(GetBlob(path, r.PathType));
                return(reader);
            }

            return(null);
        }
예제 #8
0
        public override bool ItemExists(string path)
        {
            if (PathResolver.IsLocalPath(path))
            {
                path = PathResolver.ConvertToRealLocalPath(path);
                return(File.Exists(path) || Directory.Exists(path));
            }

            try
            {
                var r      = AzureBlobPathResolver.ResolvePath(this.Client, path, skipCheckExistence: false);
                var exists = r.Exists();
                return(exists);
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #9
0
        internal IEnumerable <object> ListItems(string path)
        {
            var result = AzureBlobPathResolver.ResolvePath(this.Client, path, skipCheckExistence: false);

            switch (result.PathType)
            {
            case PathType.AzureBlobRoot:
                return(ListContainers(this.Client));

            case PathType.AzureBlobDirectory:
                return(ListDirectory(result.Directory));

            case PathType.AzureBlobBlock:
                return(ListBlob(result.Blob));

            default:
                return(null);
            }
        }
예제 #10
0
        public override bool IsItemContainer(string path)
        {
            if (PathResolver.IsLocalPath(path))
            {
                return(true);
            }

            var parts = PathResolver.SplitPath(path);

            if (parts.Count == 0)
            {
                return(true);
            }

            try
            {
                var r = AzureBlobPathResolver.ResolvePath(this.Client, path, hint: PathType.AzureBlobDirectory, skipCheckExistence: false);
                return(r.Exists());
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #11
0
        public override Stream CopyFrom(string path)
        {
            var r = AzureBlobPathResolver.ResolvePath(this.Client, path, skipCheckExistence: false);

            return(r.Blob.OpenRead());
        }
예제 #12
0
        public override bool HasChildItems(string path)
        {
            var r = AzureBlobPathResolver.ResolvePath(this.Client, path, hint: PathType.AzureBlobDirectory, skipCheckExistence: false);

            return(r.Exists());
        }