Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
bvdcode committed Oct 17, 2024
2 parents 2377dcb + 102eb80 commit 2de4eb2
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Sources/EasyExtensions.WebDav/WebDavCloudClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public async Task<IEnumerable<WebDavResource>> GetResourcesAsync(string folder)
{
return Array.Empty<WebDavResource>();
}
return result.Resources;
return result.Resources.Where(x => x.Uri != url);
}

/// <summary>
Expand All @@ -180,14 +180,20 @@ public async Task<IEnumerable<WebDavResource>> GetResourcesAsync(string folder)
/// <param name="filePath"> The file path. </param>
/// <returns> The file bytes. </returns>
public async Task<byte[]> GetFileBytesAsync(string filePath)
{
if (!await ExistsAsync(filePath))
{
throw new FileNotFoundException("File not found.", filePath);
}
else
{
string url = ConcatUris(_baseAddress, filePath).ToString();
var file = await _client.GetRawFile(url);
string requestUri = ConcatUris(_baseAddress, filePath).ToString();
WebDavStreamResponse webDavStreamResponse = await _client.GetRawFile(requestUri);
using MemoryStream memoryStream = new MemoryStream();
await file.Stream.CopyToAsync(memoryStream);
byte[] bytes = memoryStream.ToArray();
return bytes;
await webDavStreamResponse.Stream.CopyToAsync(memoryStream);
return memoryStream.ToArray();
}
}

/// <summary>
/// Gets the underlying <see cref="WebDavClient"/>.
Expand Down

0 comments on commit 2de4eb2

Please sign in to comment.