mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-10 23:36:11 +01:00
bug fix: download via fm
This commit is contained in:
@@ -1481,10 +1481,10 @@ fileManager.controller('fileManagerCtrl', function ($scope, $http, FileUploader,
|
|||||||
|
|
||||||
$scope.downloadFile = function () {
|
$scope.downloadFile = function () {
|
||||||
|
|
||||||
url = "/filemanager/downloadFile";
|
url = "/filemanager/downloadFile/";
|
||||||
var downloadURL = $scope.currentPath + "/" + allFilesAndFolders[0];
|
var downloadURL = $scope.currentPath + "/" + allFilesAndFolders[0];
|
||||||
var indexPublicHTML = downloadURL.indexOf("public_html") + 11;
|
|
||||||
$window.location.href = '/preview/' + domainName + downloadURL.slice(indexPublicHTML);
|
window.location.href = url + '?domainName=' + domainName + '?downloadURL=' + downloadURL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -81,18 +81,26 @@ def changePermissions(request):
|
|||||||
|
|
||||||
def downloadFile(request):
|
def downloadFile(request):
|
||||||
try:
|
try:
|
||||||
|
userID = request.session['userID']
|
||||||
|
admin = Administrator.objects.get(pk=userID)
|
||||||
|
|
||||||
data = json.loads(request.body)
|
fileToDownload = '/home/cyberpanel.xyz/public_html/hello.txt'
|
||||||
fileToDownload = data['fileToDownload']
|
domainName = 'cyberpanel.xyz'
|
||||||
|
|
||||||
response = ''
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
if os.path.isfile(fileToDownload):
|
|
||||||
try:
|
if ACLManager.checkOwnership(domainName, admin, currentACL) == 1:
|
||||||
with open(fileToDownload, 'rb') as f:
|
pass
|
||||||
response = HttpResponse(f.read(), content_type="application/octet-stream")
|
else:
|
||||||
response['Content-Disposition'] = 'inline; filename=' + os.path.basename(fileToDownload)
|
return ACLManager.loadErrorJson('permissionsChanged', 0)
|
||||||
except Exception as e:
|
|
||||||
raise Http404
|
logging.CyberCPLogFileWriter.writeToFile('test')
|
||||||
|
|
||||||
|
response = HttpResponse(content_type='application/force-download')
|
||||||
|
response['Content-Disposition'] = 'attachment; filename=%s' % (fileToDownload.split('/')[-1])
|
||||||
|
response['X-LiteSpeed-Location'] = '%s' % (fileToDownload)
|
||||||
|
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile('test 2')
|
||||||
return response
|
return response
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|||||||
Reference in New Issue
Block a user