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
multipart/form-data doesn't work with large files #4240
Comments
@alegout re: your last comment: #4235 (comment) That's failing because of the way the test https server is set up, I added a test for multipart/form-data forms and it works once the https server is set up to accept multipart/form-data. Check out #4241 for the new test. I will try to reproduce with uploading files. |
thanks @flotwig i confirm it's passing. |
I got tests for user registration, with an avatar or without. https://gist.github.com/alegout/cb8b92125138964ea58d92e472e8e3f6
|
Thanks. Can you share the part of the Cypress test where you upload the avatar, too? |
Reading my code, the bug certainly come from this 🤔 (i have a file preview in js): cy.get('input[name="user_account[avatar]"]')
.setFile('images/fixture.jpeg'); Cypress.Commands.add(
'setFile',
{prevSubject: 'element'},
function (element, filePath, title, description, copyright) {
const mimeTypes = {
jpeg: "image/jpeg",
jpg: "image/jpeg",
png: "image/png",
pdf: "application/pdf",
};
const filePathSplitted = filePath.split('.').pop();
const mimeType = mimeTypes[filePathSplitted] !== undefined
? mimeTypes[filePathSplitted]
: null;
cy.fixture(filePath, 'base64').then(function(image) {
Cypress.Blob.base64StringToBlob(image).then(blob => {
const elementNode = element[0];
const file = new File([blob], filePath, {type: mimeType});
const dataTransfer = new DataTransfer();
dataTransfer.items.add(file);
elementNode.files = dataTransfer.files;
elementNode.dispatchEvent(new Event('change', {bubbles: true}));
});
});
}
); |
Nice, I've gotten it to reproduce: 4d5cdbf Interestingly, your code works fine in 3.3.0 for all files below a certain size - I added some tests for small file uploads and they worked fine, but once I tried uploading this 16MB image through Cypress, it got stuck around 72% every time and eventually times out. What's the filesize of your failing images, out of curiosity? |
Interesting! Thanks The file: https://ibb.co/ydWyChK 1785x117 and 496 525 octets (500 Ko) on disk |
I have another person I've had a discussion with that is getting a similar error when upgrading to 3.3.0. Original url has been obfuscated. Currently waiting for a response on whether they also are using multipart/form-data
|
I also have the problem that tests that upload files via XHR form request stopped working on 3.3.0, while they were fine on 3.2.0. It happens both, on Electron 61 and Chrome 74. I'm using the custom This is the last debug output I get:
|
The code for this is done in cypress-io/cypress#4241, but has yet to be released. |
thank you @flotwig |
Released in |
I was struggling with the file upload, after updating to version 3.3.1 it's working, Thanks 👍 |
Original comment by @alegout: #4235 (comment)
Since Cypress 3.3.0, some users can't upload files via a
<form>
to a server if the file size is over ~16kBThe text was updated successfully, but these errors were encountered: