/** * Upload file to local uploads directory * * @param {String} path * @param {Function} callback * @return {void} */ function removeFile(filePath, callback) { let destPath = path.join(uploadsDir, filePath) fs.unlink(destPath, err => callback(err)) }
async function renameBlob( article ) { var bpath = blobPath(article.clusterIdx, article.blobIdx) if (article.nameSpace == 'M') { // metadata const data = await fs.readFile ( bpath, 'utf8' ) metadata.push([article.url.toLowerCase(), data]) return fs.unlink( bpath ) } const apath = articlePath( article ) log('renameBlob', article.index, header.articleCount, bpath, '->', apath ) return fs.move( bpath, apath, { clobber: true }) }
fs.unlink(path.join(this.__path, sessionId), function (err) { if (callback) { callback(err) } })
router.delete('/:id', async(req, res) => { const book = await Book.findByIdAndDelete(req.params.id); unlink(path.resolve('./backend/public/' + book.imagePath)); res.send({message:'Book Deleted'}); })
const removeDatabase = () => { configManager.logTestMode() return fs .unlink(dbFile) .then(() => { spinnerSucceed(spinner, 'Database file deleted successfully\n') }) .catch(error => { spinner.fail('Error in deleting the database. \n') console.log(error) }) }
fse.unlink( path.join(req.file.destination, req.file.filename) ) .then(() => next()) .catch(next)
async function getScreenShotByIOS () { let data = await client.screenshot() await fs.emptyDir(SCREEN_SHOT_PATH) var imageName = `${+new Date}.png` var fullpath = `${SCREEN_SHOT_PATH}/${imageName}` try { let check = await fs.access(fullpath) await fs.unlink(fullpath) } catch (e) { await fs.writeFile(fullpath, data, 'base64') } return imageName }
// -- unlinkFile(path) { return new Promise((res, rej) => { fs.unlink(path, (err, data) => err ? rej(err) : res(data)); }); }
async removeFile(p) { try { await fs.unlink(this.resolvePath(p)); } catch (e) { if (e.code !== "ENOENT") throw e; } }
const buildPlugins = () => { let content = ''; let keys = []; const plugins =require(pluginConfigPath).web; if (plugins && plugins.length > 0) { for(let plugin of plugins){ let camelCaseKey = toLowerCamelCase(plugin.name); content += `import ${camelCaseKey} from '${plugin.name}';\n` keys.push(camelCaseKey) } content += `export default [${keys.join(',')}];` fs.outputFileSync(outputPath, content); return true; } else { if (fs.existsSync(outputPath)) { fs.unlink(outputPath) } return false; } }
const deleteLocalFile = function (options) { return new Promise((resolve, reject) => { if (typeof options === 'undefined') return reject(new Error('Delete options must be set')); if (!options.value || !options.entityName) return reject(new Error('Field value and entityName are required')); const partOfValue = options.value.split('-'); if (partOfValue.length) { const filePath = globalConf.localstorage + options.entityName + '/' + partOfValue[0] + '/' + options.value; fs.unlink(filePath, function (err) { if (err) return reject(err); if (options.type === 'picture') { //remove picture thumbnail const fileThumnailPath = globalConf.localstorage + globalConf.thumbnail.folder + options.entityName + '/' + partOfValue[0] + '/' + options.value; fs.unlink(fileThumnailPath, function (err) { if (err) console.error(err); }); } resolve(); }); } else reject(new Error('File syntaxe not valid')); }); }
/** * Delete an entry. * @param {String} key * @param {Function} fn * @api public */ remove(key, fn = noop) { key = sanitize(key) let cacheFile = path.join(this.path, key + '.json') Fs.exists(cacheFile, (isExists) => { if (!isExists) { delete this.cache[key] return fn() } Fs.unlink(cacheFile, (err) => { if (err) return fn(err) process.nextTick(() => { delete this.cache[key] fn(null) }) }) }) }
// getinfo // function to delete a file/folder function deleteItem(pp, callback) { if (pp.isDirectory === true) { fs.rmdir(pp.osFullPath, (err) => { if (err) { callback(errors(err)); } else { directoryInfo(pp, callback); } // if }); // fs.rmdir } else { fs.unlink(pp.osFullPath, (err) => { if (err) { callback(errors(err)); } else { fileInfo(pp, callback); } // if }); // fs.unlink } // if }
async function clear () { if (await fse.exists(configFile)) { await fse.unlink(configFile) } config = {} }
async function renameBlob( article ) { var bpath = blobPath(article.clusterIdx, article.blobIdx) if (article.nameSpace == 'M') { // metadata const data = await fs.readFile ( bpath, 'utf8' ) metadata.push([article.url.toLowerCase(), data]) return fs.unlink( bpath ) } const apath = articlePath( article ) log('renameBlob', article.index, header.articleCount, bpath, '->', apath ) return fs.move( bpath, apath, { clobber: true }) }