如何使用 C# 和 .NET Core 3.x 管理 AWS Cognito 用户池中的用户?在文档中找不到有关它的任何内容。
此问题与以下内容有关:ASP.NET Core Web API上传和下载文件
首先,我要感谢Powel Gerr,他帮助我理解了他的帖子(http://weblogs.thinktecture.com/pawel/2017/03/aspnet-core-webapi-performance.html)中的一些细微差别。我还有一个要解决的问题。
我的场景假设我们有一个.NET Core控制台应用程序:
private static void Main(string[] args)
{
Console.WriteLine($"Test starts at {DateTime.Now.ToString("o")}");
FileStream fileStream = new FileStream(@"C:\Windows10Upgrade\Windows10UpgraderApp.exe", FileMode.Open);
MyFile vFile = new MyFile()
{
Lenght = 0,
Path = "https://c2calrsbackup.blob.core.windows.net/containername/Windows10UpgraderApp.exe",
RelativePath = "Windows10UpgraderApp.exe"
};
Stream uploadStream = GetUploadStream(vFile).GetAwaiter().GetResult();
fileStream.CopyTo(uploadStream);
Console.WriteLine($"Test ends at {DateTime.Now.ToString("o")}");
Console.Write("Press any key to exit...");
Console.ReadKey();
}
private static async Task<Stream> GetUploadStream(MyFile myFile)
{
Stream stream = null;
try
{
using (HttpClient httpClient = new HttpClient())
{
httpClient.BaseAddress …Run Code Online (Sandbox Code Playgroud) 我有一点问题。我的环境是.NET Core 2.1中的控制台应用程序。
看下面的代码:
private static void Main(string[] args)
{
try
{
Console.WriteLine($"Test starts: {DateTime.Now.ToString("o")}");
string connectionString = "[My connection string]";
string containerName = "mycontainer";
CloudStorageAccount account = CloudStorageAccount.Parse(connectionString);
CloudBlobClient serviceClient = account.CreateCloudBlobClient();
CloudBlobContainer container = serviceClient.GetContainerReference(containerName);
container.CreateIfNotExistsAsync().Wait();
CloudBlockBlob cloudBlockBlob = container.GetBlockBlobReference($"{containerName}/Test.txt");
CloudBlobStream cloudBlobStream = cloudBlockBlob.OpenWriteAsync().Result;
string json = JsonConvert.SerializeObject(cloudBlobStream);
Console.WriteLine($"Test ends: {DateTime.Now.ToString("o")}");
}
catch (Exception e)
{
string stackTrace = e.StackTrace;
while(e != null)
{
Console.WriteLine(e.Message);
e = e.InnerException;
}
Console.WriteLine(stackTrace);
}
Console.Write("Press any key to exit...");
Console.ReadKey();
} …Run Code Online (Sandbox Code Playgroud)