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
uploadFile no longer works #99
Comments
Sorry about that. May be, I will back-off and revert the change until I figure out why this is needed and what version of Chromium are compatible. |
I published 1.15.1 with the revert. |
The |
@xvrh doesn't look like I have perms to reopen but this most definitely does result in the same stack as above. |
OK thank. I reopen and I'll investigate. This time I can't just revert the change. |
Hi @kendalsickels-wf Can you modify this kind of script to understand the difference you are seing with the new version? import 'dart:convert';
import 'dart:io';
import 'package:mime/mime.dart';
import 'package:shelf/shelf_io.dart' as shelf;
import 'package:shelf/shelf.dart' as shelf;
import 'package:puppeteer/puppeteer.dart';
void main() async {
var httpServer = await shelf.serve((request) async {
if (request.method.toLowerCase() == 'post') {
var header =
HeaderValue.parse(request.headers[HttpHeaders.contentTypeHeader]);
var boundary = header.parameters['boundary'];
print(request.headers);
await for (var part
in request.read().transform(MimeMultipartTransformer(boundary))) {
print('Part ${part.headers}');
var partHeaders =
HeaderValue.parse(part.headers['content-disposition']);
var fileName = partHeaders.parameters['filename'];
if (fileName != null) {
var fileSink = File('_received_$fileName').openWrite();
await part.pipe(fileSink);
await fileSink.close();
}
}
}
return shelf.Response.ok(utf8.encode('''
<form method="post" enctype="multipart/form-data">
<input type="file" name="my_file">
<input type="submit" value="Upload" name="submit">
</form>
'''), headers: {HttpHeaders.contentTypeHeader: 'text/html'});
}, InternetAddress.anyIPv4, 0);
var browser = await puppeteer.launch();
var page = await browser.newPage();
await page.goto('http://${httpServer.address.host}:${httpServer.port}',
wait: Until.networkIdle);
var inputFile = await page.$('input[type=file]');
await inputFile.uploadFile([File('CHANGELOG.md')]);
var submitButton = await page.$('input[type=submit]');
await submitButton.click();
await browser.close();
await httpServer.close(force: true);
} |
So after some debugging it there were a few issues at play. First, the new uploadFile changes were hitting a CSP issue with our application:
I worked around that by adding Upload was still not working. So I changed the dispatchEvent from Would you like me to put up a PR to make this change in puppeteer-dart? |
Pushed this up: #105 Changing the event type broke a few tests so I added an additional event to accommodate the need for |
Thanks for the debugging and all the information! |
After this change #98 we are seeing a failure in uploadFile
Stack:
Pinning puppeteer to 1.14.1 works around the issue in the meantime.
The text was updated successfully, but these errors were encountered: