我正面临一个问题,请你帮忙。 我正在设置一部分代码转到文件夹,并从首页上的列表中删除文件,但也在文件系统中删除。 问题是,当我正在执行操作时,我在浏览器的控制台中收到错误:500内部服务器错误。 当我查看REQUEST URL时,似乎路径似乎正确,但停在/ deleteFile /并且没有到达文件的名称。
Angular Code
$scope.deleteFile = (idx) ->
console.log($scope.fileList)
file = $scope.fileList[idx]
Theme.deleteFile {name: file.name}
.$promise.then (response) ->
if (response.status is 200)
$scope.fileList.splice(idx, 1)
else
$scope.fileList.splice(idx, 1)
删除功能和远程方法
Theme.deleteFile = (name, next) ->
fs.unlink('/applis/tnuv/www/vizir/uploads/' + name, (err)) ->
if err
console.log 'Deletion failed'
else
console.log 'Successfully deleted'
next()
Theme.remoteMethod 'deleteFile',
accepts: [
{ arg: 'name', type: 'string', required: true, http: {source: 'path'} }
]
http:
verb: 'delete'
path: 'deleteFile/:name'
玉码
md-subheader.md-no-sticky(ng-show="fileList.length" layout="row" layout-align="center center" style="background-color:#ff5252; color:#000000") Uploaded files
md-list-item.make-scrollable(ng-repeat='item in fileList')
p
a(href="") {{ item }}
p Document
p Success
md-button.md-icon-button.md-primary.md-hue-0.limitElipsis.a.deleteHandle(ng-click="deleteFile($index)")
md-icon(md-menu-origin md-svg-icon="trash")