Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(storage/azure.py): Add content_type option for .gz files #2713

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion kernelci/storage/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from urllib.parse import urljoin
import os
from azure.storage.fileshare import ShareServiceClient
from azure.storage.blob import ContentSettings
from . import Storage


Expand All @@ -31,7 +32,7 @@
credential=self.credentials
)

def _get_directory(self, share, path):

Check warning on line 35 in kernelci/storage/azure.py

View workflow job for this annotation

GitHub Actions / Lint

Method could be a function
directoryp = share.get_directory_client(directory_path=path)
if not directoryp.exists():
# split directory path into components
Expand Down Expand Up @@ -68,7 +69,11 @@
for src, dst in file_paths:
file_client = root.get_file_client(file_name=dst)
with open(src, 'rb') as src_file:
file_client.upload_file(src_file)
c_type = 'application/octet-stream'
if src.endswith('.gz'):
c_type = 'application/gzip'
c_settings = ContentSettings(content_type=c_type)
file_client.upload_file(src_file, content_settings=c_settings)
urls[dst] = urljoin(
self.config.base_url,
'/'.join([self.config.share, dest_path, dst]),
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ readme = "README.md"
requires-python = ">=3.9"
license = {text = "LGPL-2.1-or-later"}
dependencies = [
"azure-storage-blob==12.23.1",
"azure-storage-file-share==12.13.0",
"bson==0.5.10",
"click==8.1.3",
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
azure-storage-blob==12.23.1
azure-storage-file-share==12.13.0
bson==0.5.10
click==8.1.3
Expand Down
Loading