Skip to content

Commit

Permalink
download: setting the filename of the content of the file indices to …
Browse files Browse the repository at this point in the history
…their original value
  • Loading branch information
psaiz committed Dec 20, 2024
1 parent 19e37eb commit 4655407
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions cernopendata/modules/records/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,28 @@

"""Implementention of various utility functions."""

import itertools
import json
import re
import sys
from os.path import basename
from re import sub
import six
import itertools

import flask
import six
from flask import abort, current_app, jsonify, render_template, request
from invenio_files_rest.models import FileInstance
from invenio_files_rest.views import ObjectResource
from invenio_records.api import Record
from invenio_records_files.utils import record_file_factory

from invenio_files_rest.models import FileInstance

# from invenio_files_rest.models import FileInstance, ObjectVersion
# from invenio_records.errors import MissingModelError
from invenio_records_ui.utils import obj_or_import_string
from invenio_xrootd import EOSFileStorage
from werkzeug.utils import import_string

from invenio_search import current_search_client
from invenio_search.engine import dsl, search

import sys
import flask
import re
from invenio_xrootd import EOSFileStorage
from werkzeug.utils import import_string


def get_file_index(pid, record, file_index, **kwargs):
Expand Down Expand Up @@ -100,11 +98,14 @@ def file_download_ui(pid, record, _record_file_factory=None, **kwargs):
obj = ObjectResource.get_object(
file["bucket"], file["key"], file["version_id"]
)
# Let's overwrite the key of the object, so that the downloads has the same name
# Note that the basename could not have been used as the key, since multiple files could
# have the same basename inside a file index
obj.key = basename(obj.file.uri)
if not obj:
abort(404)
else:
obj = fileobj.obj

# Check permissions
ObjectResource.check_object_permission(obj)

Expand Down

0 comments on commit 4655407

Please sign in to comment.