Skip to content
Snippets Groups Projects

Remove base64 encoding from files that contain plain text

Merged Jacques Erasmus requested to merge fix-base64-encoded-file-uploads into master
All threads resolved!
1 file
+ 10
8
Compare changes
  • Side-by-side
  • Inline
@@ -61,29 +61,31 @@ describe('new dropdown upload', () => {
const binaryTarget = {
result: 'base64,w4I=',
};
const file = {
name: 'file',
const textFile = {
name: 'textFile',
type: 'text/plain',
};
const binaryFile = {
name: 'binaryFile',
type: 'image/png',
};
it('creates file in plain text (without encoding) if the file content is plain text', () => {
vm.createFile(textTarget, file);
vm.createFile(textTarget, textFile);
expect(vm.$emit).toHaveBeenCalledWith('create', {
name: file.name,
name: textFile.name,
type: 'blob',
content: 'plain text',
base64: false,
});
});
file.type = 'image/png';
it('splits content on base64 if binary', () => {
vm.createFile(binaryTarget, file);
vm.createFile(binaryTarget, binaryFile);
expect(vm.$emit).toHaveBeenCalledWith('create', {
name: file.name,
name: binaryFile.name,
type: 'blob',
content: binaryTarget.result.split('base64,')[1],
base64: true,
Loading