|
19 | 19 |
|
20 | 20 | """Implementention of various utility functions."""
|
21 | 21 |
|
| 22 | +import itertools |
22 | 23 | import json
|
| 24 | +import re |
| 25 | +import sys |
| 26 | +from os.path import basename |
23 | 27 | from re import sub
|
24 |
| -import six |
25 |
| -import itertools |
26 | 28 |
|
| 29 | +import flask |
| 30 | +import six |
27 | 31 | from flask import abort, current_app, jsonify, render_template, request
|
| 32 | +from invenio_files_rest.models import FileInstance |
28 | 33 | from invenio_files_rest.views import ObjectResource
|
29 | 34 | from invenio_records.api import Record
|
30 | 35 | from invenio_records_files.utils import record_file_factory
|
31 | 36 |
|
32 |
| -from invenio_files_rest.models import FileInstance |
33 |
| - |
34 | 37 | # from invenio_files_rest.models import FileInstance, ObjectVersion
|
35 | 38 | # from invenio_records.errors import MissingModelError
|
36 | 39 | from invenio_records_ui.utils import obj_or_import_string
|
37 |
| -from invenio_xrootd import EOSFileStorage |
38 |
| -from werkzeug.utils import import_string |
39 |
| - |
40 | 40 | from invenio_search import current_search_client
|
41 | 41 | from invenio_search.engine import dsl, search
|
42 |
| - |
43 |
| -import sys |
44 |
| -import flask |
45 |
| -import re |
| 42 | +from invenio_xrootd import EOSFileStorage |
| 43 | +from werkzeug.utils import import_string |
46 | 44 |
|
47 | 45 |
|
48 | 46 | def get_file_index(pid, record, file_index, **kwargs):
|
@@ -100,11 +98,14 @@ def file_download_ui(pid, record, _record_file_factory=None, **kwargs):
|
100 | 98 | obj = ObjectResource.get_object(
|
101 | 99 | file["bucket"], file["key"], file["version_id"]
|
102 | 100 | )
|
| 101 | + # Let's overwrite the key of the object, so that the downloads has the same name |
| 102 | + # Note that the basename could not have been used as the key, since multiple files could |
| 103 | + # have the same basename inside a file index |
| 104 | + obj.key = basename(obj.file.uri) |
103 | 105 | if not obj:
|
104 | 106 | abort(404)
|
105 | 107 | else:
|
106 | 108 | obj = fileobj.obj
|
107 |
| - |
108 | 109 | # Check permissions
|
109 | 110 | ObjectResource.check_object_permission(obj)
|
110 | 111 |
|
|
0 commit comments