2 回答

TA貢獻(xiàn)1798條經(jīng)驗 獲得超3個贊
但是我不知道如何為服務(wù)器端設(shè)置.NET核心Web API
請參考文件上傳官方教程 以創(chuàng)建服務(wù)器端。例如,添加POST方法,如下面的示例代碼所示,以使用上面顯示的客戶端代碼接收UWP客戶端發(fā)送的文件。
// POST api/values
[HttpPost]
public async Task<IActionResult> Post(IFormFile myFile)
{
// full path to file in temp location, you could change this
var filePath = Path.GetTempFileName();
if (myFile.Length > 0)
{
using (var stream = new FileStream(filePath, FileMode.Create))
{
await myFile.CopyToAsync(stream);
}
}
// process uploaded files
// Don't rely on or trust the FileName property without validation.
return Ok(new { filePath, myFile.Length });
}
更多詳細(xì)信息,您還可以參考官方樣本。
- 2 回答
- 0 關(guān)注
- 190 瀏覽
添加回答
舉報