Closed 0-don closed 2 years ago
I would like to know how to upload a file to specific folder?
const storage = await new Storage({ email: process.env.MEGA_EMAIL, password: process.env.MEGA_PASSWORD, }).ready; let folder = storage.root.children?.find( (e) => e.name === process.env.MEGA_DIR ); if (!folder) folder = await storage.mkdir({ name: process.env.MEGA_DIR }); const file = await storage.upload(fileName, jsonFile) .complete; await file.moveTo(folder); const link = await file.link({ noKey: false }); return link;
currently I am doing it like this but I wanted to ask if there is an easier way?
it would be nice to do something like this so it parses the string for the filename and creates the missing folders if they dont exist.
const file = await storage.upload("./folder/folder1/" + fileName, jsonFile)
I would like to know how to upload a file to specific folder?
currently I am doing it like this but I wanted to ask if there is an easier way?
it would be nice to do something like this so it parses the string for the filename and creates the missing folders if they dont exist.