我具有Core MVC应用程序,对于特定实体,我具有以下模型:
(async () =>
{
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
let url = "https://www.mutualart.com/Artists";
console.log(`Fetching page data for : ${url}...`);
await page.goto(url);
await page.waitForSelector(".item.col-xs-3");
let arrMainLinks = await page.evaluate(() =>
{
return Array.from(document.querySelectorAll('.item.col-xs-3 > a'));
});
console.log(arrMainLinks.length);
for (let i = 0; i < arrMainLinks.length; i++) //get the main links
{
await page.evaluate((a) =>
{
return ([...document.querySelectorAll('.item.col-xs-3 > a')][a] as HTMLElement ).click();
}, i);
await page.waitForNavigation();
let arrSubLinks2 = await page.evaluate(() =>
{
return Array.from(document.querySelectorAll('.slide>a'));
});
console.log(arrSubLinks2.length);
for (let j = 0; j < arrSubLinks2.length; j++)
{
console.log('███AAA');
await page.evaluate((a) =>
{
return ([...document.querySelectorAll('.slide>a')][a] as HTMLElement) .click();
}, j);
await page.waitForNavigation();
let ddd: ElementHandle[] = await page.$$('.artist-name');
console.log(ddd.length);
console.log('███BBB');
await page.waitFor(2000);
await page.goBack();
console.log('███CCC');
}
await page.waitFor(2000);
await page.goBack();
}
await browser.close();
})();
根据>>HERE<<的文档,为了上传图像,我在视图模型中使用了public class Aktualnosci
{
public long ID { get; set; }
public string Tytul { get; set; }
public string Tresc { get; set; }
public DateTime Dzien { get; set; }
public byte[] AktualnosciImage { get; set; }
}
属性,该属性由控制器调用:
IFormFile
它用于创建和编辑实体。现在,我很难在控制器的public class AktualnosciCreateVM
{
public long ID { get; set; }
[Required(ErrorMessage = "Proszę wypełnić pole.")]
[StringLength(40, ErrorMessage = "Max 40 znaków.")]
public string Tytul { get; set; }
[Required(ErrorMessage = "Proszę wypełnić pole.")]
public string Tresc { get; set; }
[Required(ErrorMessage = "Proszę wypełnić pole.")]
public DateTime Dzien { get; set; }
public IFormFile AktualnosciImage { set; get; }
}
方法中解析public IFormFile AktualnosciImage { set; get; }
和public byte[] AktualnosciImage { get; set; }
来返回viewmodel:
GET
编译错误为:
无法将类型'byte []'隐式转换为 'Microsoft.AspNetCore.Http.IFormFile'
有什么方法可以解析这两个属性?