将IFormFILe
更改为流列表文件后,是否要上传$HTML_return_string .= "<option value='.$row['imie'].' '.$row['nazwisko']'"."name='$row['imie'].' '.$row['nazwisko']'>".$row['imie'].' '.$row['nazwisko']."</option>";
列表?
答案 0 :(得分:0)
这就是我用来在Azure Blob中上传文件的内容:
public interface IFileStorageService
{
Task<string> UploadImageAsync(IFormFile imageFile);
Task<string> UploadVideoAsync(IFormFile videoFile);
}
public class FileStorageService : IFileStorageService
{
private readonly Uri _baseUri = new Uri("YourBlobUrl");
private readonly CloudBlobClient _client;
public FileStorageService()
{
_client = new CloudBlobClient(_baseUri, new StorageCredentials("accoutName", "YourSecretKey"));
}
public async Task<string> UploadImageAsync(IFormFile imageFile)
{
try
{
StreamReader streamReader = new StreamReader(imageFile.OpenReadStream());
var container = _client.GetContainerReference("images");
var blob = container.GetBlockBlobReference(imageFile.FileName +".jpg");
await blob.UploadFromStreamAsync(streamReader.BaseStream);
return new Uri(_baseUri, $"/images/{imageFile.FileName}.jpg").ToString();
}
catch (Exception exception)
{
throw;
}
}
public async Task<string> UploadVideoAsync(IFormFile videoFile)
{
try
{
StreamReader videoStream = new StreamReader(videoFile.OpenReadStream());
var container = _client.GetContainerReference("videos");
var blob = container.GetBlockBlobReference(videoFile.FileName+".mp4");
await blob.UploadFromStreamAsync(videoStream.BaseStream);
return new Uri(_baseUri, $"/videos/{videoFile.FileName}.mp4").ToString();
}
catch (Exception exception)
{
throw;
}
}
}
现在,您可以通过迭代IFormFile
的列表来使用它来上传IFormFile
的列表。