Skip to content

Commit

Permalink
Merge pull request #22 from nspcc-dev/use-extensions-for-mimes
Browse files Browse the repository at this point in the history
push: use file extensions for MIME types
  • Loading branch information
roman-khimov authored May 9, 2024
2 parents ae78945 + 518b7f6 commit 33fab0a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion push-to-neofs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import subprocess
import argparse
import magic
import mimetypes
import distutils.util
from helpers.neofs import neofs_cli_execute

Expand Down Expand Up @@ -188,7 +189,9 @@ def get_file_info(directory: str, url_path_prefix: str, strip_prefix: bool):
for subdir, dirs, files in os.walk(base_path):
for filename in files:
filepath = os.path.join(subdir, filename)
mime_type = magic.from_file(filepath, mime=True)
mime_type = mimetypes.guess_type(filepath)[0]
if not mime_type:
mime_type = magic.from_file(filepath, mime=True)
relative_path = os.path.relpath(filepath, relative_base)

if url_path_prefix is not None and url_path_prefix != "":
Expand Down

0 comments on commit 33fab0a

Please sign in to comment.