

$ file -I test_asset_02.mp4
test_asset_02.mp4: video/mp4; charset=binary
Trying to upload a video/mp4 with binary encoding fails, I used the same command for Jpegs and such and they work perfect.
Upload an video/mp4 with binary encoding
Cypress: 3.5.0 , operating system: locally OSX but running against a production server (Unix), browser: Electron
Hi @teophilus
Thanks for submitting the issue!
Can you please provide the code snippet? It seems it should work, as binary is one of the supported encodings:
https://github.com/abramenal/cypress-file-upload/blob/master/src/constants.js#L29
I have same issue, here's my code snippet:
.fixture('sample_video.mp4')
.then(fileContent => {
cy.get('#upload-video').upload({
fileContent,
fileName: 'sample_video.mp4',
mimeType: 'video/mp4',
encoding: 'binary'
})
})
But I'm getting different error.

I got it fixed by setting encoding to 'utf8'.
.fixture('bear.mp4')
.then(fileContent => {
cy.get('#upload-video').upload({
fileContent,
fileName: 'bear.mp4',
mimeType: 'video/mp4',
encoding: 'utf8'
})
})
@jackguoAtJogg
Thanks for this!
@all-contributors add @jackguoAtJogg for question
@abramenal
I've put up a pull request to add @jackguoAtJogg! :tada:
Mentioned the workaround in 97e2f46d426bc57d1befc51072cea384161cba69
Wow~ is my honor to be part the contributor~ 馃榿
Hello, in my case where I used mp4box library to have a check on video metadata before sending a video, the above workaround does not work. It produces wrong video metadata. The below workaround works:
I got it fixed by setting encoding to 'utf8'.
.fixture('bear.mp4') .then(fileContent => { cy.get('#upload-video').upload({ fileContent, fileName: 'bear.mp4', mimeType: 'video/mp4', encoding: 'utf8' }) })
The upload not longer work with Cypress 7.3.0 and cypress-file-upload 5.0.7, all you need to do is to change from upload to attachFile.
Hello, in my case where I used mp4box library to have a check on video metadata before sending a video, the above workaround does not work. It produces wrong video metadata. The below workaround works:
- set encoding to base64 in cy.fixture()
- set encoding in cypress-file-upload .attachFile to base64.
Hello,
Thank you for this, however, I'm trying to upload large or small video files then accepted, in order to test the right error message. The following result is obtained:

Hello, in my case where I used mp4box library to have a check on video metadata before sending a video, the above workaround does not work. It produces wrong video metadata. The below workaround works:
- set encoding to base64 in cy.fixture()
- set encoding in cypress-file-upload .attachFile to base64.
for others this is what worked for me:
cy.fixture('vidtest.mp4', { encoding: 'base64' }).then((fileContent) => {
cy.get('[data-testid="video-component-upload-dropzone-input"]').attachFile({
fileContent,
fileName: 'vidtest.mp4',
mimeType: 'video/mp4',
encoding: 'base64'
});
});
Hello, in my case where I used mp4box library to have a check on video metadata before sending a video, the above workaround does not work. It produces wrong video metadata. The below workaround works:
- set encoding to base64 in cy.fixture()
- set encoding in cypress-file-upload .attachFile to base64.
for others this is what worked for me:
cy.fixture('vidtest.mp4', { encoding: 'base64' }).then((fileContent) => { cy.get('[data-testid="video-component-upload-dropzone-input"]').attachFile({ fileContent, fileName: 'vidtest.mp4', mimeType: 'video/mp4', encoding: 'base64' }); }); ```
This works great for me, excluding uploading large video files
I'm not getting any errors when following the above, but I am however still seeing issues with the video encoding and the output is not playable by the browser. Any suggestions would be helpful.
Versions:
"cypress-file-upload": "^5.0.7",
"cypress": "8.0.0",
Most helpful comment
I got it fixed by setting encoding to 'utf8'.