diff --git a/packages/puter-js/src/modules/FileSystem/operations/upload.js b/packages/puter-js/src/modules/FileSystem/operations/upload.js index b32da230..ab8778ea 100644 --- a/packages/puter-js/src/modules/FileSystem/operations/upload.js +++ b/packages/puter-js/src/modules/FileSystem/operations/upload.js @@ -122,7 +122,11 @@ const upload = async function(items, dirPath, options = {}){ entries[i].filepath = entries[i].name; entries[i].fullPath = entries[i].name; } - } + } + // Anything else is invalid + else { + return error({ code: 'field_invalid', message: 'upload() items parameter is an invalid type' }); + } // Will hold directories and files to be uploaded let dirs = []; diff --git a/packages/puter-js/src/modules/FileSystem/operations/write.js b/packages/puter-js/src/modules/FileSystem/operations/write.js index 6ed2fd1a..c1319ad4 100644 --- a/packages/puter-js/src/modules/FileSystem/operations/write.js +++ b/packages/puter-js/src/modules/FileSystem/operations/write.js @@ -46,6 +46,11 @@ const write = async function (targetPath, data, options = {}) { if(!data) data = new File([data ?? ''], filename); + // data should be a File now. If it's not, it's an unsupported type + if (!(data instanceof File)) { + throw new Error({ code: 'field_invalid', message: 'write() data parameter is an invalid type' }); + } + // perform upload return this.upload(data, parent, options); }