/// <summary> /// Azure DataLakeGen2 Item constructor /// </summary> /// <param name="item">datalake gen2 listout item</param> public AzureDataLakeGen2Item(PathItem item, DataLakeFileSystemClient fileSystem, bool fetchProperties = false) { this.Name = item.Name; this.Path = item.Name; this.ListPathItem = item; this.IsDirectory = item.IsDirectory is null ? false : item.IsDirectory.Value; DataLakePathClient pathclient = null; if (this.IsDirectory) // Directory { this.Directory = fileSystem.GetDirectoryClient(item.Name); pathclient = this.Directory; } else //File { this.File = fileSystem.GetFileClient(item.Name); pathclient = this.File; } this.Owner = item.Owner; this.Group = item.Group; this.Permissions = PathPermissions.ParseSymbolicPermissions(item.Permissions); this.LastModified = item.LastModified; this.Length = item.ContentLength is null ? 0 : item.ContentLength.Value; if (fetchProperties) { this.Properties = pathclient.GetProperties(); this.AccessControl = pathclient.GetAccessControl(); this.ACL = PSPathAccessControlEntry.ParsePSPathAccessControlEntrys(this.AccessControl.AccessControlList); this.ContentType = Properties.ContentType; } }
/// <summary> /// Azure DataLakeGen2 Item constructor /// </summary> /// <param name="blobDir">Cloud blob Directory object</param> public AzureDataLakeGen2Item(DataLakeDirectoryClient directoryClient) { Name = directoryClient.Name; Path = directoryClient.Path; Directory = directoryClient; IsDirectory = true; if (directoryClient.Path != "/" || string.IsNullOrEmpty(directoryClient.Path)) //if root directory, GetProperties() will fail. Skip until this is fixed. { try { Properties = directoryClient.GetProperties(); Length = Properties.ContentLength; ContentType = Properties.ContentType; LastModified = Properties.LastModified; } catch (global::Azure.RequestFailedException e) when(e.Status == 403 || e.Status == 404) { // skip get dir properties if don't have read permission } } try { AccessControl = directoryClient.GetAccessControl(); Permissions = AccessControl.Permissions; ACL = PSPathAccessControlEntry.ParsePSPathAccessControlEntrys(AccessControl.AccessControlList); Owner = AccessControl.Owner; Group = AccessControl.Group; } catch (global::Azure.RequestFailedException e) when(e.Status == 403 || e.Status == 404) { // skip get dir ACL if don't have read permission } }
/// <summary> /// Azure DataLakeGen2 Item constructor /// </summary> /// <param name="blob">CloudBlockBlob blob object</param> public AzureDataLakeGen2Item(DataLakeFileClient fileClient) { Name = fileClient.Name; Path = fileClient.Path; File = fileClient; IsDirectory = false; try { Properties = fileClient.GetProperties(); Length = Properties.ContentLength; ContentType = Properties.ContentType; LastModified = Properties.LastModified; } catch (global::Azure.RequestFailedException e) when(e.Status == 403 || e.Status == 404) { // skip get file properties if don't have read permission } try { AccessControl = File.GetAccessControl(); Permissions = AccessControl.Permissions; ACL = PSPathAccessControlEntry.ParsePSPathAccessControlEntrys(AccessControl.AccessControlList); Owner = AccessControl.Owner; Group = AccessControl.Group; } catch (global::Azure.RequestFailedException e) when(e.Status == 403 || e.Status == 404) { // skip get file ACL if don't have read permission } }
/// <summary> /// Azure DataLakeGen2 Item constructor /// </summary> /// <param name="blob">CloudBlockBlob blob object</param> public AzureDataLakeGen2Item(DataLakeFileClient fileClient) { Name = fileClient.Name; Path = fileClient.Path; File = fileClient; Properties = fileClient.GetProperties(); AccessControl = File.GetAccessControl(); Length = Properties.ContentLength; ContentType = Properties.ContentType; LastModified = Properties.LastModified; IsDirectory = false; Permissions = AccessControl.Permissions; ACL = PSPathAccessControlEntry.ParsePSPathAccessControlEntrys(AccessControl.AccessControlList); Owner = AccessControl.Owner; Group = AccessControl.Group; }
/// <summary> /// Azure DataLakeGen2 Item constructor /// </summary> /// <param name="blobDir">Cloud blob Directory object</param> public AzureDataLakeGen2Item(DataLakeDirectoryClient directoryClient) { Name = directoryClient.Name; Path = directoryClient.Path; Directory = directoryClient; IsDirectory = true; if (directoryClient.Path != "/") //if root directory, GetProperties() will fail. Skip until this is fixed. { Properties = directoryClient.GetProperties(); Length = Properties.ContentLength; ContentType = Properties.ContentType; LastModified = Properties.LastModified; } AccessControl = directoryClient.GetAccessControl(); Permissions = AccessControl.Permissions; ACL = PSPathAccessControlEntry.ParsePSPathAccessControlEntrys(AccessControl.AccessControlList); Owner = AccessControl.Owner; Group = AccessControl.Group; }