Skip to content

Commit

Permalink
feat: ability to delete files from local file storage
Browse files Browse the repository at this point in the history
  • Loading branch information
meenahoda committed Mar 30, 2022
1 parent 7ee13e2 commit fc45eba
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions lib/components/services/localfilestorage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@ class LocalFilestorage {
return {
Name: content.name,
Path: path.join(resolvedFolderPath, content.name),
launches: [{
stateMachineName: 'tymly_downloadFromLocalFileStorage_1_0',
title: 'Download',
input: {
localFolderPath: this.downloadDir,
remoteFilePath: path.join(resolvedFolderPath, content.name)
launches: [
{
stateMachineName: 'tymly_downloadFromLocalFileStorage_1_0',
title: 'Download',
input: {
localFolderPath: this.downloadDir,
remoteFilePath: path.join(resolvedFolderPath, content.name)
}
}
}]
]
}
})

Expand All @@ -56,6 +58,15 @@ class LocalFilestorage {
}
} // listFolderContentsFromPath

async deleteFile (folderPath, fileName) {
const localFilePath = path.join(folderPath, fileName)
const rootedFilePath = this.resolvePath(localFilePath)

if (!rootedFilePath) return

await fsp.unlink(rootedFilePath)
} // deleteFile

async copyFileToRemotePath (localFilePath, remoteFolderPath, remoteFileName = null) {
const localFile = path.resolve(localFilePath)
const rootedPath = this.resolvePath(remoteFolderPath)
Expand Down Expand Up @@ -91,8 +102,8 @@ class LocalFilestorage {
function cloudstorageService (options) {
const cloudstorage = dottie.get(options, 'bootedServices.cloudstorage')

if (!cloudstorage) bootOops("Can't find cloudstorage in bootedServices.")
if (!cloudstorage.registerProvider) bootOops("cloudstorage doesn't have registerProvider method")
if (!cloudstorage) bootOops('Can\'t find cloudstorage in bootedServices.')
if (!cloudstorage.registerProvider) bootOops('cloudstorage doesn\'t have registerProvider method')

return options.bootedServices.cloudstorage
} // cloudstorageService
Expand Down

0 comments on commit fc45eba

Please sign in to comment.