Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions SW.Bitween.Api/Resources/Adapters/Metadata.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using SW.PrimitiveTypes;

namespace SW.Bitween.Resources.Adapters;

[HandlerName("Metadata")]
public class Metadata : IGetHandler<string,object>
public class Metadata : IGetHandler<string, object>
{
private readonly ServerlessOptions _serverlessOptions;
private readonly ICloudFilesService _cloudFilesService;
private readonly NativeAdapterDiscoveryService _nativeAdapterDiscovery;

public Metadata(
ServerlessOptions serverlessOptions,
ICloudFilesService cloudFilesService
ICloudFilesService cloudFilesService,
NativeAdapterDiscoveryService nativeAdapterDiscovery
)
{
_serverlessOptions = serverlessOptions;
_cloudFilesService = cloudFilesService;
_nativeAdapterDiscovery = nativeAdapterDiscovery;
}

public async Task<object> Handle(string key)
{
var decodedKey = Uri.UnescapeDataString(key);

if (decodedKey.StartsWith(NativeAdapterDiscoveryService.NativePrefix, StringComparison.OrdinalIgnoreCase))
return new { };

var cloudFilesList =
await _cloudFilesService.GetMetadataAsync(
$"{_serverlessOptions.AdapterRemotePath}/{key}"
$"{_serverlessOptions.AdapterRemotePath}/{decodedKey}"
);

return cloudFilesList;
Expand Down