我正在创建一个应用,其中
[如果可能,我想
因此,我在POST方法中添加了“ DownloadTextAsync()”方法,但是好像我在错误的主题上调用了该方法?
[HttpPost("UploadText")] public async Task<IActionResult> Post(List<IFormFile> files) { string connectionString = Environment.GetEnvironmentVariable("mykeystringhere"); // Create a BlobServiceClient object which will be used to create a container client BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString); //Create a unique name for the container string containerName = "textdata" + Guid.NewGuid().ToString(); // Create the container and return a container client object BlobContainerClient containerClient = await blobServiceClient.CreateBlobContainerAsync(containerName); // Create a local file in the ./data/ directory for uploading and downloading string localPath = "./data/"; string fileName = "textfiledata" + Guid.NewGuid().ToString() + ".txt"; string localFilePath = Path.Combine(localPath, fileName); // Get a reference to a blob BlobClient blobClient = containerClient.GetBlobClient(fileName); // Open the file and upload its data using FileStream uploadFileStream = System.IO.File.OpenRead(localFilePath); await blobClient.UploadAsync(uploadFileStream, true); uploadFileStream.Close(); string downloadFilePath = localFilePath.Replace(".txt", "DOWNLOAD.txt"); // Get the blob file as text string contents = blobClient.DownloadTextAsync().Result; //return the string return contents; //if (uploadSuccess) // return View("UploadSuccess"); //else // return View("UploadError"); }
我遇到的问题是
我知道'blobClient'是对Blob的引用,我可以在其中获取文件的数据,但这一定是错误的?
另外,似乎无法使用“ CloudBlobContainer”或“ CloudBlockBlob blob”。是因为在POST方法内部,blob刚刚被初始化并且在执行这两个命令时不存在吗?
另外,当我测试POST方法时,控制台会抛出“拒绝加载字体”,因为它违反了以下内容安全策略指令:“ default-src'none'”。请注意,'font-src'未明确设置,因此'default-src'被用作后备。”我用谷歌搜索但不知道这意味着什么吗?我尝试了不同的方法,但一直无法发布/“但无法真正找到可靠的答案。可能与我的POST方法有关吗?
我正在创建一个应用程序,用户可以在其中上传文本文件,然后找到最常用的单词并在文本中更改该单词,然后向用户显示更改后的文本。如果可能,我想得到...
我知道'blobClient'是对Blob的引用,可以获取文件的数据,但这一定是错误的吗?