asp.net ReadAsMultipartAsync在net 6中不可用

x8diyxa7  于 2023-01-18  发布在  .NET
关注(0)|答案(1)|浏览(150)

我想知道如何替换这个方法。我使用netider6,内容和方法readasmultipartasync不可用。
示例代码:

private async Task<bool> readPart(MultipartFormDataStreamProvider provider)
{
    try
    {
       InMemoryMultipartFormDataStreamProvider provider = null;
        provider = await  Request.Content.ReadAsMultipartAsync(new 
        InMemoryMultipartFormDataStreamProvider());

        ResumableConfiguration configuration = GetUploadConfiguration(provider);
                int chunkNumber = GetChunkNumber(provider);

        // Rename generated file
        MultipartFileData chunk = provider.FileData[0]; // Only one file in multipart message
                RenameChunk(chunk, chunkNumber, configuration.Identifier);

        // Assemble chunks into single file if they're all here
        TryAssembleFile(configuration);
                return true;
    }
    catch 
    {
        return false;
    }
}

我是说这条线

provider = await  Request.Content.ReadAsMultipartAsync(new InMemoryMultipartFormDataStreamProvider());

谢谢
问候

evrscar2

evrscar21#

你可以用类似

public async Task<ResponseDto> APIMethod([FromForm] DataType object)

这将从窗体读取数据
对象包含类似于

public List<IFormFile> Files { get; set; } = new List<IFormFile>();

IFormFile将表示使用Form推送到服务器的文件

相关问题