Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Commit

Permalink
Merge branch 'feature/56520-upload-keep-file-extension' into 'master'
Browse files Browse the repository at this point in the history
fix: [#56520] keep file extensions

See merge request rammearkitektur/ra-clients!259
  • Loading branch information
Carl Bordum Hansen committed Oct 6, 2023
2 parents 11790cf + 5386a10 commit 3dfda51
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions raclients/upload.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2021 Magenta ApS <https://magenta.dk>
# SPDX-License-Identifier: MPL-2.0
from contextlib import contextmanager
from tempfile import NamedTemporaryFile
from tempfile import TemporaryDirectory
from typing import Any
from typing import Callable
from typing import Generator
Expand Down Expand Up @@ -68,8 +68,10 @@ def file_uploader(settings: Any, filename: str) -> Generator[str, None, None]:
auth_realm = "mo"
mora_base = settings["mora.base"]

with NamedTemporaryFile() as fp:
tmp_filename = fp.name
# We use a temporary directory so we can control the file name, as some
# programs behaviour depends on the file extension.
with TemporaryDirectory() as d:
tmp_filename = f"{d}/{filename}"
yield tmp_filename
upload_file(
client_id,
Expand Down

0 comments on commit 3dfda51

Please sign in to comment.