Dateien werden gelöscht im Standard wenn auch in Cloud
This commit is contained in:
parent
fc35ce24ac
commit
15363595d8
|
|
@ -26,4 +26,5 @@ urlpatterns = [
|
||||||
# EXTERNAL FROM NC
|
# EXTERNAL FROM NC
|
||||||
path('logout/<str:uid>', views.apilogout, name="api-logout"),
|
path('logout/<str:uid>', views.apilogout, name="api-logout"),
|
||||||
path('uschanged/<str:uid>/<str:sid>', views.userChangedInNc, name="api-userchanged"),
|
path('uschanged/<str:uid>/<str:sid>', views.userChangedInNc, name="api-userchanged"),
|
||||||
|
path('deletefile/<slug:fid>/<slug:secretkey>', views.deleteNCFile, name="api-deletencfile"),
|
||||||
]
|
]
|
||||||
15
api/views.py
15
api/views.py
|
|
@ -440,3 +440,18 @@ def NCSwitchStandardFiles(request):
|
||||||
standard.addedfiles_nc.add(ncfile)
|
standard.addedfiles_nc.add(ncfile)
|
||||||
return JsonResponse({"status" : response_status})
|
return JsonResponse({"status" : response_status})
|
||||||
return JsonResponse({"status" : "NO AUTH"})
|
return JsonResponse({"status" : "NO AUTH"})
|
||||||
|
|
||||||
|
@api_view(['GET'], )
|
||||||
|
def deleteNCFile(request, fid, secretkey):
|
||||||
|
if request.method == "GET":
|
||||||
|
if(secretkey == '87zuhjk87GHJ546tzgvhas76aaskbdhr45edfVHAKia87s6gbAVGFGSR3451627gBHAKJBN'):
|
||||||
|
try:
|
||||||
|
file_to_del = NCFile.objects.filter(nc_id=fid).first()
|
||||||
|
file_to_del.delete()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return JsonResponse({"status" : 'true'})
|
||||||
|
else:
|
||||||
|
return JsonResponse({"status" : "NO AUTH"})
|
||||||
|
else:
|
||||||
|
return JsonResponse({"status" : "NO AUTH"})
|
||||||
Binary file not shown.
|
|
@ -1141,7 +1141,6 @@ def getNCFileInfosURL(request, ncid):
|
||||||
try:
|
try:
|
||||||
filesearchdata = '<?xml version="1.0" encoding="UTF-8"?><d:searchrequest xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"><d:basicsearch><d:select><d:prop><d:displayname/></d:prop></d:select><d:from><d:scope><d:href>/files/' + request.user.username + '</d:href><d:depth>infinity</d:depth></d:scope></d:from><d:where><d:eq><d:prop><oc:fileid/></d:prop><d:literal>' + str(ncid) + '</d:literal></d:eq></d:where></d:basicsearch></d:searchrequest>'
|
filesearchdata = '<?xml version="1.0" encoding="UTF-8"?><d:searchrequest xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"><d:basicsearch><d:select><d:prop><d:displayname/></d:prop></d:select><d:from><d:scope><d:href>/files/' + request.user.username + '</d:href><d:depth>infinity</d:depth></d:scope></d:from><d:where><d:eq><d:prop><oc:fileid/></d:prop><d:literal>' + str(ncid) + '</d:literal></d:eq></d:where></d:basicsearch></d:searchrequest>'
|
||||||
r = requests.request("SEARCH", settings.NEXTCLOUD_URL + "remote.php/dav/", data=filesearchdata, headers={'Content-Type' : 'text/xml', 'Authorization' : "Bearer " + request.user.profile.nc_sid})
|
r = requests.request("SEARCH", settings.NEXTCLOUD_URL + "remote.php/dav/", data=filesearchdata, headers={'Content-Type' : 'text/xml', 'Authorization' : "Bearer " + request.user.profile.nc_sid})
|
||||||
print(r.text)
|
|
||||||
split_response = r.text.split("<d:href>")
|
split_response = r.text.split("<d:href>")
|
||||||
split_fileele = split_response[1].split("</d:href>")
|
split_fileele = split_response[1].split("</d:href>")
|
||||||
# Return file-link except first slash in string
|
# Return file-link except first slash in string
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue