【发布时间】:2021-07-09 16:15:06
【问题描述】:
我正在开发 Microsoft Azure 存储服务的 .NETCore Web API 项目。
我有一个服务层 BlobService 正在实现 IBlobService 接口
public interface IBlobService
{
public Task<BlobInfo> GetBlobAsync(string name);
}
其中 BlobInfo 是一个自定义类:
public class BlobInfo
{
public BlobInfo(Stream content, string contentType)
{
Content = content;
ContentType = contentType;
}
public Stream Content { get; set; }
public string ContentType { get; set; }
}
BlobService 服务:
public class BlobService : IBlobService
{
public readonly BlobServiceClient _blobServiceClient;
public BlobService(BlobServiceClient blobServiceClient)
{
_blobServiceClient = blobServiceClient;
}
public async Task<BlobInfo> GetBlobAsync(string name)
{
var containerClient = _blobServiceClient.GetBlobContainerClient("videos");
var blobClient = containerClient.GetBlobClient(name);
var blobDownloadInfo = await blobClient.DownloadAsync();
return new BlobInfo(blobDownloadInfo.Value.Content, blobDownloadInfo.Value.ContentType);
}
}
在这一层出现一个错误,简而言之Task
【问题讨论】:
-
请将错误添加为文本,而不是图像(如果可以的话)。
-
从你的接口方法定义中移除
public。 -
@Fildor 我也写了我的查询,但以防万一有人想看到我添加图像的确切错误。
-
或者您定义了多个
BlobInfo?简而言之,可能是名称冲突,或者您可能需要尝试进行清理并重建。
标签: c# asp.net asp.net-mvc asp.net-web-api azure-storage