diff --git a/CHANGELOG.md b/CHANGELOG.md index c8c40a4e..0f916b1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed UX bug when jobs pagination is reset after changing a job () - Progressbars in CLI for file uploading and downloading () - `utils/cli` changed to `cvat-cli` package () +- Support custom file name for backup () ### Changed - Bumped nuclio version to 1.8.14 () diff --git a/cvat/apps/engine/backup.py b/cvat/apps/engine/backup.py index 58a01184..262c06b6 100644 --- a/cvat/apps/engine/backup.py +++ b/cvat/apps/engine/backup.py @@ -701,6 +701,8 @@ def _create_backup(db_instance, Exporter, output_path, logger, cache_ttl): def export(db_instance, request): action = request.query_params.get('action', None) + filename = request.query_params.get('filename', None) + if action not in (None, 'download'): raise serializers.ValidationError( "Unexpected action specified for the request") @@ -745,14 +747,14 @@ def export(db_instance, request): timestamp = datetime.strftime(last_project_update_time, "%Y_%m_%d_%H_%M_%S") - filename = "{}_{}_backup_{}{}".format( + filename = filename or "{}_{}_backup_{}{}".format( filename_prefix, db_instance.name, timestamp, - os.path.splitext(file_path)[1]) + os.path.splitext(file_path)[1]).lower() location = location_conf.get('location') if location == Location.LOCAL: return sendfile(request, file_path, attachment=True, - attachment_filename=filename.lower()) + attachment_filename=filename) elif location == Location.CLOUD_STORAGE: @validate_bucket_status diff --git a/cvat/apps/engine/views.py b/cvat/apps/engine/views.py index d48f4136..e840dead 100644 --- a/cvat/apps/engine/views.py +++ b/cvat/apps/engine/views.py @@ -487,6 +487,8 @@ class ProjectViewSet(viewsets.ModelViewSet, UploadMixin, AnnotationMixin, Serial OpenApiParameter('action', location=OpenApiParameter.QUERY, description='Used to start downloading process after backup file had been created', type=OpenApiTypes.STR, required=False, enum=['download']), + OpenApiParameter('filename', description='Backup file name', + location=OpenApiParameter.QUERY, type=OpenApiTypes.STR, required=False), OpenApiParameter('location', description='Where need to save downloaded backup', location=OpenApiParameter.QUERY, type=OpenApiTypes.STR, required=False, enum=Location.list()), @@ -707,6 +709,8 @@ class TaskViewSet(UploadMixin, AnnotationMixin, viewsets.ModelViewSet, Serialize OpenApiParameter('action', location=OpenApiParameter.QUERY, description='Used to start downloading process after backup file had been created', type=OpenApiTypes.STR, required=False, enum=['download']), + OpenApiParameter('filename', description='Backup file name', + location=OpenApiParameter.QUERY, type=OpenApiTypes.STR, required=False), OpenApiParameter('location', description='Where need to save downloaded backup', location=OpenApiParameter.QUERY, type=OpenApiTypes.STR, required=False, enum=Location.list()),