Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Filetype is not detected on setInputFiles #5543

Closed
kobenguyent opened this issue Mar 26, 2020 · 5 comments
Closed

[BUG] Filetype is not detected on setInputFiles #5543

kobenguyent opened this issue Mar 26, 2020 · 5 comments

Comments

@kobenguyent
Copy link

Context:

Puppeteer Version: 2.1.1
Operating System: MacOS

await el.setInputFiles('avatar.jpg')
await page.click('input[type=submit]');

Expected:
filetype to be image/jpeg

Actual file:

{
  name: 'avatar.jpg',
  type: 'application/octet-stream',
  tmp_name: '/tmp/phpe1S4NZ',
  error: 0,
  size: 5621
}

The file is not empty but the file type is not detected. There is a second parameter of filetype in setInputFiles where I can specify a filetype. However, I assume this is a bug because the same test passes for older versions.

@m1m1s1ku
Copy link

m1m1s1ku commented Mar 28, 2020

Related to : #5358 ?

Had same issues, enforced Pptr 2.0 and works ok, 2.1.0 introduce the mimeType bug

@kobenguyent
Copy link
Author

Related to : #5358 ?

Had same issues, enforced Pptr 2.0 and works ok, 2.1.0 introduce the mimeType bug

Yeah, it is. Thanks for pointing it out!

@DavertMik
Copy link

@mathiasbynens please could you take a look?
At CodeceptJS we run our tests across different engines and this is part of our test suite.
File detection works for WebDriver, Puppeteer 1.20 & Playwright but was broken since 2.0 and is still not fixed in 3.0.

@mathiasbynens
Copy link
Member

mathiasbynens commented Apr 16, 2020

@paullewis is gonna take a look at the remaining filepicker problems: #5654

@paullewis
Copy link
Contributor

This should be fixed in 532ae57.

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('about:blank');
  await page.setContent('<input type="file">')

  const el = await page.evaluateHandle(() => document.querySelector('input'));
  await el.uploadFile('avatar.jpg')
  const type = await page.$eval('input', picker => picker.files[0].type);

  console.log(type);  // image/jpeg
  await browser.close();
})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants