From 0ff73548e93759d653dd8b91753e531893bb2e4e Mon Sep 17 00:00:00 2001 From: Julien CAPUL Date: Thu, 9 Oct 2025 17:20:21 +0200 Subject: [PATCH 1/2] Add support for pdf and zip binary types --- src/drive.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/drive.ts b/src/drive.ts index 504720f..a49b549 100644 --- a/src/drive.ts +++ b/src/drive.ts @@ -375,7 +375,7 @@ export class FileSystemDrive implements Contents.IDrive { let format: Contents.FileFormat; let fileContent: any = null; - // We assume here image, audio and video mimetypes are all and only binary files we'll encounter + // We assume here image, audio, video, zip and pdf mimetypes are all and only binary files we'll encounter if ( file.type && file.type.split('/') && @@ -383,7 +383,17 @@ export class FileSystemDrive implements Contents.IDrive { ) { format = 'base64'; } else { - format = 'text'; + if ( + [ + 'application/zip', + 'application/pdf', + 'application/octet-stream' + ].includes(file.type) + ) { + format = 'base64'; + } else { + format = 'text'; + } } if (content) { From 27c989cbc68258acba31cc32242dc022181a3e1e Mon Sep 17 00:00:00 2001 From: Julien CAPUL Date: Thu, 9 Oct 2025 18:24:16 +0200 Subject: [PATCH 2/2] Refactor base64 conditions in single if --- src/drive.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/drive.ts b/src/drive.ts index a49b549..e440a22 100644 --- a/src/drive.ts +++ b/src/drive.ts @@ -378,22 +378,17 @@ export class FileSystemDrive implements Contents.IDrive { // We assume here image, audio, video, zip and pdf mimetypes are all and only binary files we'll encounter if ( file.type && - file.type.split('/') && - ['image', 'audio', 'video'].includes(file.type.split('/')[0]) - ) { - format = 'base64'; - } else { - if ( + ((file.type.split('/') && + ['image', 'audio', 'video'].includes(file.type.split('/')[0])) || [ 'application/zip', 'application/pdf', 'application/octet-stream' - ].includes(file.type) - ) { - format = 'base64'; - } else { - format = 'text'; - } + ].includes(file.type)) + ) { + format = 'base64'; + } else { + format = 'text'; } if (content) {