mirror of https://github.com/jumpserver/jumpserver
fix(config = settings.TERMINAL_REPLAY_STORAGE.items()):
parent
813e10ed11
commit
166a3fff5c
|
@ -4,12 +4,15 @@ from collections import OrderedDict
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
|
import boto3 # AWS S3 sdk
|
||||||
|
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.core.files.storage import default_storage
|
from django.core.files.storage import default_storage
|
||||||
from django.http import HttpResponseNotFound
|
from django.http import HttpResponseNotFound
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
from rest_framework import viewsets, serializers
|
from rest_framework import viewsets, serializers
|
||||||
from rest_framework.views import APIView, Response
|
from rest_framework.views import APIView, Response
|
||||||
from rest_framework.permissions import AllowAny
|
from rest_framework.permissions import AllowAny
|
||||||
|
@ -23,7 +26,6 @@ from .hands import IsSuperUserOrAppUser, IsAppUser, \
|
||||||
IsSuperUserOrAppUserOrUserReadonly
|
IsSuperUserOrAppUserOrUserReadonly
|
||||||
from .backends import get_command_store, get_multi_command_store, \
|
from .backends import get_command_store, get_multi_command_store, \
|
||||||
SessionCommandSerializer
|
SessionCommandSerializer
|
||||||
import boto3 # AWS S3 sdk
|
|
||||||
|
|
||||||
logger = logging.getLogger(__file__)
|
logger = logging.getLogger(__file__)
|
||||||
|
|
||||||
|
@ -280,11 +282,11 @@ class SessionReplayViewSet(viewsets.ViewSet):
|
||||||
url = default_storage.url(path)
|
url = default_storage.url(path)
|
||||||
return redirect(url)
|
return redirect(url)
|
||||||
else:
|
else:
|
||||||
config = self.app.config.get("REPLAY_STORAGE", None)
|
config = settings.TERMINAL_REPLAY_STORAGE.items()
|
||||||
if config:
|
if config:
|
||||||
for name in config.keys():
|
for name, value in config:
|
||||||
if config[name].get("TYPE", '') == "s3":
|
if value.get("TYPE", '') == "s3":
|
||||||
client, bucket = self.s3Client(config[name])
|
client, bucket = self.s3Client(value)
|
||||||
try:
|
try:
|
||||||
client.head_object(Bucket=bucket, Key=path)
|
client.head_object(Bucket=bucket, Key=path)
|
||||||
client.download_file(bucket, path, default_storage.base_location + '/' + path)
|
client.download_file(bucket, path, default_storage.base_location + '/' + path)
|
||||||
|
|
Loading…
Reference in New Issue